Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Compare values in multiple rows in one column using awk Post 303043947 by RudiC on Tuesday 11th of February 2020 04:24:18 PM
Old 02-11-2020
Try also (after some guesswork)

Code:
awk -F, '{IX = $1 FS $2} IX == OX && $8 - O8 > 1; {OX = IX; O8 = $8}' file
    47329,39785,2,12,28,351912.53,2533118.81,172.91,1
    47329,39797,2,12,28,352062.77,2533104.67,173.63,1
    47329,39821,2,12,10,352362.49,2533118.77,175.27,1

 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Compare two files using awk or sed, add values in a column if their previous fields are same

Hi All, I have two files file1: abc,def,ghi,5,jkl,mno pqr,stu,ghi,10,vwx,xyz cba,ust,ihg,4,cdu,oqw file2: ravi,def,kishore ramu,ust,krishna joseph,stu,mike I need two output files as follows In my above example, each row in file1 has 6 fields and each row in file2 has 3... (1 Reply)
Discussion started by: yerruhari
1 Replies

2. UNIX for Dummies Questions & Answers

Compare two files using awk or sed, add values in a column if their previous fields are same

Hi All, I have two files file1: abc,def,ghi,5,jkl,mno pqr,stu,ghi,10,vwx,xyz cba,ust,ihg,4,cdu,oqw file2: ravi,def,kishore ramu,ust,krishna joseph,stu,mike I need two output files as follows In my above example, each row in file1 has 6 fields and each row in file2 has 3... (1 Reply)
Discussion started by: yerruhari
1 Replies

3. Shell Programming and Scripting

Compare two files using awk or sed, add values in a column if their previous fields are same

Hi All, I have two files file1: abc,def,ghi,5,jkl,mno pqr,stu,ghi,10,vwx,xyz cba,ust,ihg,4,cdu,oqw file2: ravi,def,kishore ramu,ust,krishna joseph,stu,mike I need two output files as follows In my above example, each row in file1 has 6 fields and each row in file2 has 3... (3 Replies)
Discussion started by: yerruhari
3 Replies

4. Shell Programming and Scripting

How to compare the values of a column in awk in a same file and consecutive lines..

I would like to compare the values of 2nd column of consecutive lines of same file in such a way so that if the difference between first value and second value is more than 100 it should print complete line else ignore line. Input File ========== PDB 2500 RTDB 123 RTDB-EAGLE 122 VSCCP 2565... (4 Replies)
Discussion started by: manuswami
4 Replies

5. Shell Programming and Scripting

Compare values in two files. For matching rows print corresponding values from File 1 in File2.

- I have two files (File 1 and File 2) and the contents of the files are mentioned below. - I am trying to compare the values of Column1 of File1 with Column1 of File2. If a match is found, print the corresponding value from Column2 of File1 in Column5 of File2. - I tried to modify and use... (10 Replies)
Discussion started by: Santoshbn
10 Replies

6. UNIX for Dummies Questions & Answers

Compare values of fields from same column with awk

Hi all ! If there is only one single value in a column (e.g. column 1 below), then return this value in the same output column. If there are several values in the same column (e.g. column 2 below), then return the different values separated by "," in the output. pipe-separated input: ... (11 Replies)
Discussion started by: lucasvs
11 Replies

7. Shell Programming and Scripting

awk Print New Column For Every Two Lines and Match On Multiple Column Values to print another column

Hi, My input files is like this axis1 0 1 10 axis2 0 1 5 axis1 1 2 -4 axis2 2 3 -3 axis1 3 4 5 axis2 3 4 -1 axis1 4 5 -6 axis2 4 5 1 Now, these are my following tasks 1. Print a first column for every two rows that has the same value followed by a string. 2. Match on the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

8. Shell Programming and Scripting

How to compare the values of a column in a same file using awk?

Dear Unix experts, I have got a file where I would like to compare the values of second column if first column is same in such a way that the difference between the values is >50. If not, I would like to discard both values. For example, my input file looks like - comp275_c0_seq2 73... (7 Replies)
Discussion started by: utritala
7 Replies

9. Shell Programming and Scripting

Compare two files column values using awk

Judi # cat File1 judi /export/home 76 judi /usr 83 judi # judi # cat File2 judi /export/home 79 judi /usr 82 judi # if COLUMN3 of File2 is greater that COLUMN3 of File1, then print File2's lines juid /export/home 79 Code tags please (2 Replies)
Discussion started by: judi
2 Replies
PDOSTATEMENT.FETCHCOLUMN(3)						 1					       PDOSTATEMENT.FETCHCOLUMN(3)

PDOStatement::fetchColumn - Returns a single column from the next row of a result set

SYNOPSIS
public mixed PDOStatement::fetchColumn ([int $column_number]) DESCRIPTION
Returns a single column from the next row of a result set or FALSE if there are no more rows. Note PDOStatement.fetchColumn(3) should not be used to retrieve boolean columns, as it is impossible to distinguish a value of FALSE from there being no more rows to retrieve. Use PDOStatement.fetch(3) instead. PARAMETERS
o $column_number - 0-indexed number of the column you wish to retrieve from the row. If no value is supplied, PDOStatement.fetchColumn(3) fetches the first column. RETURN VALUES
PDOStatement.fetchColumn(3) returns a single column in the next row of a result set. Warning There is no way to return another column from the same row if you use PDOStatement.fetchColumn(3) to retrieve data. EXAMPLES
Example #1 Return first column of the next row <?php $sth = $dbh->prepare("SELECT name, colour FROM fruit"); $sth->execute(); print("Fetch the first column from the first row in the result set: "); $result = $sth->fetchColumn(); print("name = $result "); print("Fetch the second column from the second row in the result set: "); $result = $sth->fetchColumn(1); print("colour = $result "); ?> The above example will output: Fetch the first column from the first row in the result set: name = lemon Fetch the second column from the second row in the result set: colour = red SEE ALSO
PDO.query(3), PDOStatement.fetch(3), PDOStatement.fetchAll(3), PDO.prepare(3), PDOStatement.setFetchMode(3). PHP Documentation Group PDOSTATEMENT.FETCHCOLUMN(3)
All times are GMT -4. The time now is 11:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy