View previous topic :: View next topic |
Author |
Message |
Martin Beginner
Joined: 20 Mar 2006 Posts: 133 Topics: 58
|
Posted: Tue Aug 08, 2006 9:51 pm Post subject: Compare 2 files without sorting excluding some fields |
|
|
Hi ,
I'm having this problem and have been unable to crack it.
Ex:- I have 100k records in 2 files which need to be compared.
I need to match all the fields except for COLS 118:125
File 1: -
x1
x2
x3
x4
.
.
.
.
.
.
x100K
File 2 :- ( The problem here is that X1,X2 .. .records cannot be sorted as there are other records which are created dynamically... ( using the run time of the job).
Here's the file looks like..
x99
x89
x71
.
.
.
.
.
x1
.
.
.
.
.
.
x2
Now is there a way I can compare these two files.
IN general is there a way to compare 2 records If they are not sorted? I may sound stupid... But this really something that has eaten away lot my time...
I tried to solve this by using INSYNC utility, But it didn't solve the problem.
- Martin |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Wed Aug 09, 2006 7:17 am Post subject: |
|
|
Quote: |
records cannot be sorted as there are other records which are created dynamically... ( using the run time of the job).
IN general is there a way to compare 2 records If they are not sorted? I may sound stupid... But this really something that has eaten away lot my time...
|
so you want to compare line 1 of file 1 with line 1 of file 2 , line2 with line 2 and so on ?
If that is the case you can simply add a seqnum at the end of record using SEQNUM and use that as the key and compare the files.
Kolusu
PS: Try to be more descriptive with your topic titles. A simple "sort problem" is too generic. An approriate title would "Compare 2 files without sorting excluding some fields". I am changing the title. _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
Martin Beginner
Joined: 20 Mar 2006 Posts: 133 Topics: 58
|
Posted: Wed Aug 09, 2006 12:33 pm Post subject: |
|
|
Kolusu,
The porblem here is :-
File 1 is sorted and File 2 cannot be sorted, Becasue of the time paramater.
So .. Is there a way to compare a sorted file with an unsorted one ?
X1 is the first line in File1... But the same can 100 rec or 1000 rec on file 2.
Gotta.. I will be more careful while choosing the titles.
- Martin |
|
Back to top |
|
|
coolman Intermediate
Joined: 03 Jan 2003 Posts: 283 Topics: 27 Location: US
|
Posted: Wed Aug 09, 2006 2:11 pm Post subject: |
|
|
Martin,
After compare, what is that you want to do? Give a description of what you would want in the output?
________
silversurfer reviews
Last edited by coolman on Sat Feb 05, 2011 1:46 am; edited 1 time in total |
|
Back to top |
|
|
Martin Beginner
Joined: 20 Mar 2006 Posts: 133 Topics: 58
|
Posted: Wed Aug 09, 2006 2:24 pm Post subject: |
|
|
coolman,
I want write out the non matching records on to flat file.
Out put file:-
File 1 - Rec # abc
XXXXXXXXXXXXXXXXXXXXXXXXXX
File 2 - Rec # xyz
XXXXXXXXXXXXXXXXXXXXAXXXXX
- Martin |
|
Back to top |
|
|
coolman Intermediate
Joined: 03 Jan 2003 Posts: 283 Topics: 27 Location: US
|
Posted: Wed Aug 09, 2006 3:00 pm Post subject: |
|
|
Martin,
Here's my suggestion on how to do it:
1. Pad '1' and SEQNUM for file 1 , '2' and SEQNUM for file2
Code: |
INREC FIELDS=(1,80,C'1',SEQNUM,8,ZD)
INREC FIELDS=(1,80,C'2',SEQNUM,8,ZD)
|
2. Merge files 1 and 2
3. SELECT FROM(CON) TO(IN1) ON(1,2,CH) NODUPS
4.From IN1,
Code: |
SORT FIELDS=(82,8,ZD,A)
OUTFIL FNAMES=OUT1,INCLUDE=(81,1,CH,EQ,C'1')
OUTFIL SAVE,FNAMES=OUT2
|
OUT1 - would contain non matching records from file 1
OUT2 - would contain non matching records from file 2
________
easy vape
Last edited by coolman on Sat Feb 05, 2011 1:46 am; edited 1 time in total |
|
Back to top |
|
|
Martin Beginner
Joined: 20 Mar 2006 Posts: 133 Topics: 58
|
Posted: Sun Aug 13, 2006 3:49 am Post subject: |
|
|
Hi All,
Now there is a new requirement where in the new fields will be inserted into file 1 as well ( these new fields are synamically generated using the run time).
Can any one help me with this.
- Martin |
|
Back to top |
|
|
coolman Intermediate
Joined: 03 Jan 2003 Posts: 283 Topics: 27 Location: US
|
Posted: Mon Aug 14, 2006 8:15 am Post subject: |
|
|
Martin,
Post an example of your input and output that you are looking for.
________
Hino Dutro |
|
Back to top |
|
|
|
|