I have a two files and I need to create a new file with records from file1 and file2. I will try to explain the problem and what I want with a example:
File1 (ordered descending by KEY and DATE )
KEY DATE AMOUNT
AAAAA 2010-02-15 000100
AAAAA 2010-07-25 001230
AAAAA 2010-12-11 000075
BBBBB 2010-05-20 000250
BBBBB 2010-07-12 000400
BBBBB 2010-08-11 000000
AAAAA 2010-02-15 000100
AAAAA 2010-07-25 001230
AAAAA 2010-12-11 000075
BBBBB 2010-05-20 000250
BBBBB 2010-07-12 000400
BBBBB 2010-08-11 000000
File2 (ordered descending by KEY ) this file has 365 records, one by day of the 2010 year.
KEY
2010-01-01
“ “ “
“ “ “
2010-12-31
2010-01-01
“ “ “
“ “ “
2010-12-31
I need to generate a new file with 365 records for every KEY of file1 with the records from file1 and inserting new records from file2 who the date don’t exist into file1. The problem is the amount that must be some time zeros and sometime the same as the last processed record from file1.
Example:
AAAAA 2010-01-01 000000 (As 2010-01-01 exist into file2 and not in file1, generate the record from key with date from file2 and amount = 0)
AAAAA 2010-01-02 000000 (same as previous explanation)ç
“ “ “
“ “ “
AAAAA 2010-02-15 000100 (as 2010-02-15 exist into file2 we generate the same record as file1)
AAAAA 2010-02-16 000100 (as 2010-02-16 exist into file2 and not in file1, generate the record from key with date from file2 and amount = to the last file1 record processed)
AAAAA 2010-02-17 000100 (same as previous explanation)
“ “ “
“ “ “
AAAAA 2010-07-25 001230 (as 2010-07-25 exist into file2 we generate the same record as file1)
AAAAA 2010-07-26 001230 (as 2010-02-16 exist into file2 and not in file1, generate the record from key with date from file2 and amount = to the last file1 record processed)
AAAAA 2010-07-28 001230 (same as previous explanation)
“ “ “
“ “ “
AAAAA 2010-12-11 000075
AAAAA 2010-12-12 000075 (as 2010-12-12 exist into file2 and not in file1, generate the record from key with date from file2 and amount = to the last file1 record processed)
AAAAA 2010-12-13 000075 (same as previous explanation)
“ “ “
“ “ “
AAAAA 2010-12-31 000075 (same as previous explanation)
BBBBB 2010-01-01 000000 (THE KEY CHANGE, As 2010-01-01 exist into file2 and not in file1, generate the record from key with date from file2 and amount = 0)
BBBBB 2010-01-02 000000 (same as previous explanation)ç
“ “ “
“ “ “
BBBBB 2010-05-20 000250 (as 2010-05-20 exist into file2 we generate the same record as file1)
BBBBB 2010-05-21 000250 (as 2010-05-21 exist into file2 and not in file1, generate the record from key with date from file2 and amount = to the last file1 record processed)
BBBBB 2010-05-22 000250 (same as previous explanation)
“ “ “
“ “ “
BBBBB 2010-07-12 000400 (as 2010-07-12 exist into file2 we generate the same record as file1)
BBBBB 2010-07-13 000400 (as 2010-02-13 exist into file2 and not in file1, generate the record from key with date from file2 and amount = to the last file1 record processed)
BBBBB 2010-07-14 000400 (same as previous explanation)
“ “ “
“ “ “
BBBBB 2010-08-11 000000 (as 2010-08-11 exist into file2 we generate the same record as file1)
BBBBB 2010-08-12 000000 (as 2010-08-12 exist into file2 and not in file1, generate the record from key with date from file2 and amount = to the last file1 record processed)
BBBBB 2010-08-13 000000 (same as previous explanation)
“ “ “
“ “ “
BBBBB 2010-12-31 000075 (same as previous explanation)