Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to merge 3 files on matching criteria?

Status
Not open for further replies.

shaokat

Technical User
Oct 8, 2002
11
IN
I have 3 file. Main file <File 1>, Reference File A <File 2> and B <File 3>.

- There may or may not exist a Matching ID and Mailing Address in each reference file.
- For each matching ID and Mailing address from reference file A and B, the set of records have to be &quot;moved&quot; to the main file right after the matching record of MAIN file.
- The reference file A and B should have all its matched records removed.

The output files expected are shown here as <Result File 4>,<Result File 5> and <Result File 6>.

Any help will be appreciated.


<FILE 1:> MAIN FILE.
================================================================================
RECORD1
RECORD1 MAILING NAME MAILING ADDRESS 1 MAILING ADDRESS 2
RECORD1 ID# 0011223344
RECORD1
RECORD2
RECORD2 MAILING NAME MAILING ADDRESS 1 MAILING ADDRESS 2
RECORD2 ID# 0022334411
RECORD2
RECORD3
RECORD3 MAILING NAME MAILING ADDRESS 1 MAILING ADDRESS 2
RECORD3 ID# 0033441122
RECORD3
RECORD4
RECORD4 MAILING NAME MAILING ADDRESS 1 MAILING ADDRESS 2
RECORD4 ID# 0044112233
RECORD4
================================================================================

<FILE 2:> REFERENCE FILE A
==============================
1
-
0 MAILING NAME
MAILING ADDRESS 1
MAILING ADDRESS 2
- ID# 0011223344
DESCRIPTION:BMW
1
-
0 MAILING NAME
MAILING ADDRESS 1
MAILING ADDRESS 2
- ID# 0022334411
DESCRIPTION:HONDA
1
-
0 MAILING NAME
MAILING ADDRESS 1
MAILING ADDRESS 2
- ID# 0033441155
DESCRIPTION:TOYOTA
1
-
0 MAILING NAME
MAILING ADDRESS 1
MAILING ADDRESS 2
- ID# 0044112233
DESCRIPTION:FORD
===============================

<FILE 3:> REFERENCE FILE B
===============================
1
-
0 MAILING NAME
MAILING ADDRESS 1
MAILING ADDRESS 2
- ID# 0011223344
DESCRIPTION:Z3
1
-
0 MAILING NAME
MAILING ADDRESS 1
MAILING ADDRESS 2
- ID# 0033441122
DESCRIPTION:TT
1
-
0 MAILING NAME
MAILING ADDRESS 1
MAILING ADDRESS 2
- ID# 1122334455
DESCRIPTION:MERCEDEZ
===============================




<RESULT FILE 4:> UPDATED MAIN FILE.
================================================================================
RECORD1
RECORD1 MAILING NAME MAILING ADDRESS 1 MAILING ADDRESS 2
RECORD1 ID# 0011223344
RECORD1
1
-
0 MAILING NAME
MAILING ADDRESS 1
MAILING ADDRESS 2
- ID# 0011223344
DESCRIPTION:BMW
1
-
0 MAILING NAME
MAILING ADDRESS 1
MAILING ADDRESS 2
- ID# 0011223344
DESCRIPTION:Z3
RECORD2
RECORD2 MAILING NAME MAILING ADDRESS 1 MAILING ADDRESS 2
RECORD2 ID# 0022334411
RECORD2
1
-
0 MAILING NAME
MAILING ADDRESS 1
MAILING ADDRESS 2
- ID# 0022334411
DESCRIPTION:HONDA
RECORD3
RECORD3 MAILING NAME MAILING ADDRESS 1 MAILING ADDRESS 2
RECORD3 ID# 0033441122
RECORD3
1
-
0 MAILING NAME
MAILING ADDRESS 1
MAILING ADDRESS 2
- ID# 0033441122
DESCRIPTION:TT
RECORD4
RECORD4 MAILING NAME MAILING ADDRESS 1 MAILING ADDRESS 2
RECORD4 ID# 0044112233
RECORD4
1
-
0 MAILING NAME
MAILING ADDRESS 1
MAILING ADDRESS 2
- ID# 0044112233
DESCRIPTION:FORD
================================================================================


<RESULT FILE 5:> NEW REFERENCE FILE A WITH NON-MATCHED RECORDS
==================================
1
-
0 MAILING NAME
MAILING ADDRESS 1
MAILING ADDRESS 2
- ID# 0033441155
DESCRIPTION:TOYOTA
==================================

<RESULT FILE 6:> NEW REFERENCE FILE B WITH NON-MATCHED RECORDS
==================================
1
-
0 MAILING NAME
MAILING ADDRESS 1
MAILING ADDRESS 2
- ID# 1122334455
DESCRIPTION:MERCEDEZ
==================================
 
could you show us what you have somefar - it might tell us a bit more of where you're stuck.

Are you stuck or just lazy?

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
I tried and got stuck so I was wondering if there was any new method out there I could learn.

-Lazy
 
could you share your 'old' method - it might be newER than our new one.

-Tenacious

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Crazy stuff.
If people really think that they can just dial-in
and get $50/hr labor for free they will.
I will not offer solutions for more than trivial
problems anymore. This is HS.
 
hmm.... i should probably ask for a raise, eh?

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top