I am hoping that someone will be able to help me out, basically I have a text file that I need to split based on a variable that will be contained within the file…..
I have added below an example of how the source file would look…
What I need to do is ignore the header and footer and then split the file in to separate files based on the second delimiter so for the first row this would be “1001” the files should group all of the matching references into the file and then apply a header and footer.
Header should be a variable (in this example it should be the first delimiter) and the footer should be the count of records, the file then needs to be saved with a variable name (see below)
Source file example:
Header is Here|1
Testcust1|1001|thisis 1
Testcust1|1001|thisis 2
Testcust1|1001|thisis 3
Testcust1|1001|thisis 4
Testcust2|1002|thisis 1
Testcust2|1002|thisis 2
Testcust3|1003|thisis 3
Testcust4|1004|thisis 1
Testcust4|1004|thisis 2
Testcust4|1004|thisis 3
Testcust1|1001|thisis 5
Testcust1|1001|thisis 6
Testcust1|1001|thisis 7
Testcust1|1001|thisis 8
Testcust1|1001|thisis 9
Footer|15
Below is what I would expect the first output file to look like based on the source:
Testcust1|1
Testcust1|1001|thisis 1
Testcust1|1001|thisis 2
Testcust1|1001|thisis 3
Testcust1|1001|thisis 4
Testcust1|1001|thisis 5
Testcust1|1001|thisis 6
Testcust1|1001|thisis 7
Testcust1|1001|thisis 8
Testcust1|1001|thisis 9
Footer|9
This needs to be saved as “C:\Testcust1(Datetime).txt”
Help would be greatly appreciated!