Steve Jennings
asked on
Parsing a flat file, how to create a csv file
I have a very large file that looks (more or less) like:
I: Steve
1234 Oak
Apt 5
City
I: Jack
99 Elm
Town
I: Dave
123 Pine
Suite 444
Mail stop 5
Village
And I want it to look like:
Steve, 1234 Oak, Apt 5, City
Jack, 99 Elm, Town
Dave, 123 Pine, Suite 444, Mail stop 5, Village
Each block of customer data begins with an "I:" and is followed by a name. Basically, if every "block" of data was the same number of lines, say 4, I'd just loop through the file and create a "record" for every four lines of the file. But in my file, some of the "blocks" are 3 lines and some are as much as 10. I know a new "block" begins with an "I:", but I cant figure out . . . well, hopefully you get the idea.
This is a one-time task, so a quick and dirty solution is fine.
Thanks
Steve
I: Steve
1234 Oak
Apt 5
City
I: Jack
99 Elm
Town
I: Dave
123 Pine
Suite 444
Mail stop 5
Village
And I want it to look like:
Steve, 1234 Oak, Apt 5, City
Jack, 99 Elm, Town
Dave, 123 Pine, Suite 444, Mail stop 5, Village
Each block of customer data begins with an "I:" and is followed by a name. Basically, if every "block" of data was the same number of lines, say 4, I'd just loop through the file and create a "record" for every four lines of the file. But in my file, some of the "blocks" are 3 lines and some are as much as 10. I know a new "block" begins with an "I:", but I cant figure out . . . well, hopefully you get the idea.
This is a one-time task, so a quick and dirty solution is fine.
Thanks
Steve
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER