View previous topic :: View next topic
|
Author |
Message |
kenar.t
New User
Joined: 13 Feb 2013 Posts: 2 Location: INDIA
|
|
|
|
Hi,
Need Help on below.
I have input file with data below. f1,f2,f3,q1,q2 are the field names that mentioned here for understanding purpose, below them actual data that each field contains.
q1 contains postive value or zeros
q2 contains negative value or zeros
Have to sort the input file based on f1,f2,f3 and the output file we should get a unique record which has a non zero value.
Could you please let us know how to do this.
I have given the input and output file conents for better understanding.
Input file:
Code: |
f1 f2 f3 q1 q2
abc def ghi 0 0
abc def ghi 20 0
abc def ghi 20 0
abc def ghi 20 0
pqr stu vwx 0 0
pqr stu vwx 0 -90
pqr stu vwx 0 -90 |
Output file should contains
Code: |
abc def ghi 20 0
pqr stu vwx 0 -90 |
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
How about OMIT where q1 and q2 equal zero.
You could then do a simple SUM with FIELDS=NONE (with you data shown). |
|
Back to top |
|
|
kenar.t
New User
Joined: 13 Feb 2013 Posts: 2 Location: INDIA
|
|
|
|
Have forgot to include one scenario, i have one more record in the the input file as below, this should also appear in my output file
My output file looks like this.
Code: |
abc cde fgh 20 0
ijk lmn opq 0 0
pqr stu vwx 0 -90 |
|
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Omit all the records with two 0 except for this ijk lmn opq 0 0
Which is OMIT q1 and q2 equal 0 and f1 not equal to ijk , f2 is not equal to lmn and f3 not equal to opq
and do SUM FIELDS=NONE |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Are all your non-zero values always guaranteed to be the same?
Have a look at ICETOOL's SELECT operator. Sort on your three key fields AND the s new key field which you make by adding together the two numeric values, and sort on that descending.
Use FIRST on ICETOOL. |
|
Back to top |
|
|
|