Compare to seperate files 
Author Message
 Compare to seperate files

Howzit

I have been trying to write a script that compares two similar files and
updates the changes , I have been trying for two days and cannot get it
right.  FileA is the Table that needs to be updated and fileB is the table
with the latest records.  The third field in FILEA needs to be comapared
with the first field in FILEB

FileA
002233791|10001|7|Romiko van de dronker|021/54007/13
002233792|10001|7|Romiko van de dronker|022/54007/14
002333745|10002|14|Bob Harrison|021/53014/12
002543578|10003|16|Harry Ford|429/85016/11

FileB
7|Romiko van de dronker|021/54007/13
7|Romiko van de dronker|022/54007/14
8|Michael Bake|021/69008/12
14|Bob Harrison|021/53014/12
16|Harry Ford|429/85016/11
16|Harry Ford|430/85016/12
200|Joe Blogs|021/54200/13
23333|Gary Player|022/23333/45

OUTPUT1
002233791|10001|7|Romiko van de dronker|021/54007/13
002233792|10001|7|Romiko van de dronker|022/54007/14
8|Michael Bake|021/69008/12
002333745|10002|14|Bob Harrison|021/53014/12
002543578|10003|16|Harry Ford|429/85016/11
16|Harry Ford|430/85016/12
200|Joe Blogs|021/54200/13
23333|Gary Player|022/23333/45

OUTPUT2
8|Michael Bake|021/69008/12
16|Harry Ford|430/85016/12
200|Joe Blogs|021/54200/13
23333|Gary Player|022/23333/45

As you can see I need to take the changes in FILEB and compare them to FileA
and then output the changes, also notice that Harry has opened another
account and his customer number stays the same (16).

Guys, I tried using GETLINE and FILENAME in a BEGIN statement and it just
does not do it, I am not very experienced manipulating more than one file.
 I thought I would need to use arrays but I have tried to understand them
and I get totally lost trying to use them, I am sure once I know how to use
arrays and GETLINE then I have pretty much wrapped up awk.  Thanks for your
help guys
Romiko



Tue, 29 Jan 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Qestion on parsing files into seperate files.

2. seperate keyword and seperate compilation with Gnat?

3. Comparing file objects: what is compared?

4. How to seperate record in a text file

5. Btrieve - Seperate file for memo fields

6. OPL: Files - Seperating IO from Management

7. subroutine in seperate files

8. urlparse - seperate directory and file?

9. Calling Tcl procs in seperate files

10. Calling Tcl procs in seperate files

11. Comparing 2 files to create a third file

12. comparing an input file with an output file

 

 
Powered by phpBB® Forum Software