How to compare 2 files and combine matched criteria into a third file.

  • Hi all,

    I have a problem that i am trying to solve and can't seem to get my head round it. I have tried a couple of different ways and was wondering if anyone has already done it.

    I have a list of people in file 'ddebit.csv' that are all of the people who have a direct debit instruction. A list in file 'bank.csv' of people who already have a direct debit set up with the bank.

    So what I am trying to do is check the contents of 'ddebit.csv' against 'bank.csv' and if there is no match then copy the record from 'ddebit.csv' into a new file called 'auddis.csv' with an added field on the end called trans-type set as '0N' for New Direct Debit instruction. If the record is in 'bank.csv' and not in 'ddebit.csv' then copy the record from 'bank.csv' to 'auddis.csv' and add the field on the end called trans-type set as '0C' for Cancel Direct Debit instruction.

    Then if the record from 'ddebit.csv' is in 'bank.csv' check to see if any of the details (sort code, acc number, name) have changed and if they have write 2 records to the 'auddis.csv'. 1 to cancel the old details and 1 with a new instruction with the new details. If the details are the same in both 'ddebit.csv' and 'bank.csv' then ignore that record as no action is needed.

    So any ideas on the best way to go about this?? 🙂

  • Homework completed

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply