Posted: Thu Nov 08, 2007 6:14 pm Post subject: File comparison
I have 2 files - A & B, need to compare these files to see if a particular field in each of these files are same. If same then I need to just write out file B. Is there any tool that can do this or need to write a quick program for this.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Thu Nov 08, 2007 6:38 pm Post subject:
You haven't given enough information. Please show an example of the records in each input file (relevant fields only) and what you want for output. If there are duplicates within either file, show that in your example. Give the RECFM and LRECL of the input files. Give the starting position, length and format of all relevant fields. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Thu Nov 08, 2007 7:40 pm Post subject:
Quote:
If both files (A & B) have same information in that field, then, write output is file B.
Are you comparing record-by-record, that is, compare record1 of file1 to record1 of file2, compare record2 of file1 to record2 of file2, etc. Or are you comparing by key, that is, if any record in file1 has the same key as any record in file2?
Quote:
Need to just check position 19
I assume when you say position 19, you are not counting the RDW in positions 1-4 so you really mean position 23 ... right?
Quote:
If different, then output file should be blank.
What do you mean by this? Do you mean the record should not be in the output file or do you mean something else?
When I asked you to
Quote:
Please show an example of the records in each input file (relevant fields only) and what you want for output.
I didn't mean for you to show one input record in one file and no output records. That really doesn't help. If you can't show a proper example of several records in each input file and the expected output (just the bytes up to and including the key field will do), then I can't give you a solution. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Are you comparing record-by-record, that is, compare record1 of file1 to record1 of file2, compare record2 of file1 to record2 of file2, etc. Or are you comparing by key, that is, if any record in file1 has the same key as any record in file2?
For the field I mentioned, each file should have the same information though out the file. So just reading the 1st record and comparing that field from the 2 files is enough, donot need to compare every record.
Quote:
I assume when you say position 19, you are not counting the RDW in positions 1-4 so you really mean position 23 ... right?
Yes
Quote:
What do you mean by this? Do you mean the record should not be in the output file or do you mean something else?
No record should be written out.
Quote:
I didn't mean for you to show one input record in one file and no output records. That really doesn't help. If you can't show a proper example of several records in each input file and the expected output (just the bytes up to and including the key field will do), then I can't give you a solution.
Case1
File A Position 23,11bytes
20070824E4C
File B Position 23,11 bytes
20070824E4C
Write out all records from B to output
Case2
File A Position 23,11bytes
20070824E4C
File B Position 23,11 bytes
20070829C2I
Output is blank.
Its ok if this info is not enough, a program can be written - I was thinking for an alternate method.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Fri Nov 09, 2007 11:32 am Post subject:
Well, I think you're saying you want to take the value from the first record in file1 and use it to select the records from file2 for output. If so, then you can use this DFSORT job:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file1 (VB)
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY,STOPAFT=1
* Create DFSORT Symbol from first record of file1 as:
* TARG,'value'
OUTFIL VTOF,BUILD=(C'TARG,''',23,11,C'''',80:X)
/*
//S2 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=... input file2 (VB)
//SORTOUT DD DSN=... output file (VB)
//SYSIN DD *
OPTION COPY
* Use TARG value to select records from file2 for output
INCLUDE COND=(23,11,CH,EQ,TARG)
/*
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Thu Jan 22, 2009 11:40 am Post subject:
I don't understand what you mean. SYMNAMES can contain multiple symbols. INCLUDE works on multiple records. If an input file has multiple records with a constant on each one, OUTFIL can be used to build a symbol for each constant on a separate line for SYMNAMES.
I showed the OP a job for the example given. If you want to do something else, you need to explain what you want to do with an example. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Fri Jan 23, 2009 11:33 am Post subject:
File1 has 163451 and file2 has two records that have 163451 in position 19-24 and you show one of those file2 records for output. So can I surmise from this that you want the first record in file2 that has a match in file1 (it would have been nice if you actually gave the "rules" for what you want to do). Or do you want something else (describe in detail).
What is the maximum number of records you would have in file1? _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
File-2 will always have duplicates. So, I want the first duplicate only to be written to the output file. The maximum entries in File-1 will be not more than 7 and we don't have control over it as it is maintained by end user.
Thanks. _________________ MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Sat Jan 24, 2009 11:17 am Post subject:
Here's a DFSORT job that will do what you asked for. I assumed your input records were already in sorted order. If not change the //SORTIN01 DD to a //SORTIN DD and change the MERGE statement to a SORT statement.
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Frank, Thank you very much. I was expecting usage of SYMBOLS in the solution you given. _________________ MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
==
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Mon Jan 26, 2009 11:10 am Post subject:
The use of Symbols is NOT the best way to do that kind of thing. I gave you a more appropriate solution. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum