Sponsored Content
Top Forums UNIX for Dummies Questions & Answers deleting a row if a certain column is below a certain number Post 302402195 by Pep Puigvert on Tuesday 9th of March 2010 06:57:33 AM
Old 03-09-2010
deleting a row if a certain column is below a certain number

How can you delete a row if a certain column is bigger than a certain number?

I have the following input:

Code:
20080709 20081222 95750 1 0 0.02 94.88
20080709 20081222 95750 2 0 0.89 94.88
20080709 20081222 9575 1 0 0 94.88
20080709 20081222 9575 2 0 0 94.88
20080709 20081222 9587.5 1 0 0 94.88
20080709 20081222 9587.5 2 0 0 94.88
20080709 20081222 95875 1 0 0.015 94.88
20080709 20081222 95875 2 0 1.01 94.88
20080709 20081222 96000 1 0 0.01 94.88
20080709 20081222 96000 2 0 1.13 94.88
20080709 20081222 9600 1 0 0 94.88
20080709 20081222 9600 2 0 0 94.88

I would like to delete all rows in bold since the third column is smaller than 10000 and the result should be the lines below:

Code:
20080709 20081222 95750 1 0 0.02 94.88
20080709 20081222 95750 2 0 0.89 94.88
20080709 20081222 95875 1 0 0.015 94.88
20080709 20081222 95875 2 0 1.01 94.88
20080709 20081222 96000 1 0 0.01 94.88
20080709 20081222 96000 2 0 1.13 94.88

I have the following code in perl but is not working since I get the following error:
Use of uninitialized value in numeric gt (>) at ./format_10000.perl line 5, line 1.

Code:
#!/usr/bin/perl -w
while(<STDIN>) {
 my ( $col1, $col2, $col3, $col4, $col5, $col6, $col7 )
  = split ( /\s+/, $_ ); # split current line where you at least one space or tab...
 next if $col3> 10000;
 print STDOUT $_; # print current line. We did not chomp it, so no need for an extra \n.
}

Can anyone help me?

Thanks a lot in advance!

Pep
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

deleting a row if a certain column is below a certain number

How can you delete a row if a certain column is bigger than a certain number? I have the following input: 20080709 20081222 95750 1 0 0.02 94.88 20080709 20081222 95750 2 0 0.89 94.88 20080709 20081222 9575 1 0 0 94.88 20080709 20081222 9575 2 0 0 94.88 20080709 20081222 9587.5 1 0 0... (6 Replies)
Discussion started by: Pep Puigvert
6 Replies

2. UNIX for Dummies Questions & Answers

Adding a column with the row number using awk

Is there anyway to use awk to add a first column to my data that automatically goes from 1 to n , where n is the numbers of my rows?:confused: (4 Replies)
Discussion started by: cosmologist
4 Replies

3. Shell Programming and Scripting

Count the number or row with same value in a column

This is the source file, we called it errorlist.out 196 server_a server_unix_2 CD 196 server_b server_win_1 CD 196 server_c server_win_2 CD 196 server_bd server_unix_2 CD 196 server_d server_unix_2 CD 196 server_es server_win_1 CD 196 ... (14 Replies)
Discussion started by: sQew
14 Replies

4. Shell Programming and Scripting

How to print column based on row number

Hi, I want to print column value based on row number say multiple of 8. Input file: line 1 67 34 line 2 45 57 . . . . . . line 8 12 46 . . . . . . line 16 24 90 . . . . . . line 24 49 67 Output 46 90 67 (2 Replies)
Discussion started by: Surabhi_so_mh
2 Replies

5. Shell Programming and Scripting

Deleting a row based on fetched value of column

Hi, I have a file which consists of two columns but the first one can be varying in length like 123456789 0abcd 123456789 0abcd 4015 0 0abcd 5000 0abcd I want to go through the file reading each line, count the number of characters in the first column and delete... (2 Replies)
Discussion started by: swasid
2 Replies

6. Shell Programming and Scripting

Deleting row if all column values are a particular string

Hello, I have a very large file for which I would like to remove all rows for which the value of columns 2-5 is zero. For instance I would like this file: contig1, 0, 0, 0, 0 contig2, 1, 3, 5, 0 contig3, 0, 0, 0, 0 contig4, 0, 5, 6, 7 To become this file: contig2, 1, 3, 5,0 ... (17 Replies)
Discussion started by: mouchkam
17 Replies

7. Shell Programming and Scripting

Awk, appending a number in the first column of a row with a condition

Hi everyone, I have a data file in which the data is stored in event blocks. What I would like to get is that the same file with every data row starting with the number of event block. So here is two event blocks from my file: <event> -2 -1 0 0 0 501 0.00000000000E+00 ... (2 Replies)
Discussion started by: hayreter
2 Replies

8. Shell Programming and Scripting

awk split columns to row after N number of column

I want to split this with every 5 or 50 depend on how much data the file will have. And remove the comma on the end Source file will have 001,0002,0003,004,005,0006,0007,007A,007B,007C,007E,007F,008A,008C Need Output from every 5 tab and remove the comma from end of each row ... (4 Replies)
Discussion started by: ranjancom2000
4 Replies

9. UNIX for Beginners Questions & Answers

Select and copy .csv files based on row and column number

Dear UNIX experts, I'm a command line novice working on a Macintosh computer (Bash shell) and have neither found advice that is pertinent to my problem on the internet nor in this forum. I have hundreds of .csv files in a directory. Now I would like to copy the subset of files that contains... (8 Replies)
Discussion started by: rcsapo
8 Replies

10. UNIX for Beginners Questions & Answers

Print a row with the max number in a column

Hello, I have this table: chr1_16857_17742 - chr1 17369 17436 "ENST00000619216.1"; "MIR6859-1"; - 67 chr1_16857_17742 - chr1 14404 29570 "ENST00000488147.1"; "WASH7P"; - 885 chr1_16857_18061 - chr1 ... (5 Replies)
Discussion started by: coppuca
5 Replies
SGEEQU(l)								 )								 SGEEQU(l)

NAME
SGEEQU - compute row and column scalings intended to equilibrate an M-by-N matrix A and reduce its condition number SYNOPSIS
SUBROUTINE SGEEQU( M, N, A, LDA, R, C, ROWCND, COLCND, AMAX, INFO ) INTEGER INFO, LDA, M, N REAL AMAX, COLCND, ROWCND REAL A( LDA, * ), C( * ), R( * ) PURPOSE
SGEEQU computes row and column scalings intended to equilibrate an M-by-N matrix A and reduce its condition number. R returns the row scale factors and C the column scale factors, chosen to try to make the largest element in each row and column of the matrix B with elements B(i,j)=R(i)*A(i,j)*C(j) have absolute value 1. R(i) and C(j) are restricted to be between SMLNUM = smallest safe number and BIGNUM = largest safe number. Use of these scaling factors is not guaranteed to reduce the condition number of A but works well in practice. ARGUMENTS
M (input) INTEGER The number of rows of the matrix A. M >= 0. N (input) INTEGER The number of columns of the matrix A. N >= 0. A (input) REAL array, dimension (LDA,N) The M-by-N matrix whose equilibration factors are to be computed. LDA (input) INTEGER The leading dimension of the array A. LDA >= max(1,M). R (output) REAL array, dimension (M) If INFO = 0 or INFO > M, R contains the row scale factors for A. C (output) REAL array, dimension (N) If INFO = 0, C contains the column scale factors for A. ROWCND (output) REAL If INFO = 0 or INFO > M, ROWCND contains the ratio of the smallest R(i) to the largest R(i). If ROWCND >= 0.1 and AMAX is neither too large nor too small, it is not worth scaling by R. COLCND (output) REAL If INFO = 0, COLCND contains the ratio of the smallest C(i) to the largest C(i). If COLCND >= 0.1, it is not worth scaling by C. AMAX (output) REAL Absolute value of largest matrix element. If AMAX is very close to overflow or very close to underflow, the matrix should be scaled. INFO (output) INTEGER = 0: successful exit < 0: if INFO = -i, the i-th argument had an illegal value > 0: if INFO = i, and i is <= M: the i-th row of A is exactly zero > M: the (i-M)-th column of A is exactly zero LAPACK version 3.0 15 June 2000 SGEEQU(l)
All times are GMT -4. The time now is 07:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy