I am working on a design for a bit of code to parse a single, very large, CSV file into two different files.
The data has a reference code and a phone number like such:
101,5551112220
101,5551112225
101,5551112226
101,5551112227
102,5551112232
102,5551112233
103,5551112234
103,5551112235
103,5551112236
104,5551112240
101,5551112251
102,5551112252
What I need to do is break this data down by Reference Code and the Left(9) of the Phone number.
I suppose I could feed it into access and build tables but the requirements are more than I think a query will handle and it requires comparing to other records values.
The requirements are:
- Split by the left(9) of the phone number, take the lead number in that range and put that record into File #1.
- Put the next X records in that range in File #2 IF they have the same Reference Code.
- If the next X records in that range do not have the same Reference code as the first one, place them ALL into File #1. Meaning once a single record doesn't match in that range, everything that follows in the same Phone number range is placed into File #1.
- If the record is the ONLY one in that range, place it into File #1 and move on to the next range. This should be accounted for in the above loops but wanted to call it out specifically.
The output would be two files, one containing all the leading records and what I call the "problem" records; and the second file containing all the other records that are in the same range and have the same Ref Code as the Leading record.
I have some ideas but I wanted to bounce this off the community at large to see if anyone has done something similar before I get to coding, as I am just working on paper currently.
Paper is easier to throw than my monitor.
Thanks in advance.
The data has a reference code and a phone number like such:
101,5551112220
101,5551112225
101,5551112226
101,5551112227
102,5551112232
102,5551112233
103,5551112234
103,5551112235
103,5551112236
104,5551112240
101,5551112251
102,5551112252
What I need to do is break this data down by Reference Code and the Left(9) of the Phone number.
I suppose I could feed it into access and build tables but the requirements are more than I think a query will handle and it requires comparing to other records values.
The requirements are:
- Split by the left(9) of the phone number, take the lead number in that range and put that record into File #1.
- Put the next X records in that range in File #2 IF they have the same Reference Code.
- If the next X records in that range do not have the same Reference code as the first one, place them ALL into File #1. Meaning once a single record doesn't match in that range, everything that follows in the same Phone number range is placed into File #1.
- If the record is the ONLY one in that range, place it into File #1 and move on to the next range. This should be accounted for in the above loops but wanted to call it out specifically.
The output would be two files, one containing all the leading records and what I call the "problem" records; and the second file containing all the other records that are in the same range and have the same Ref Code as the Leading record.
I have some ideas but I wanted to bounce this off the community at large to see if anyone has done something similar before I get to coding, as I am just working on paper currently.
Paper is easier to throw than my monitor.
Thanks in advance.