I have a text file with several different sections. Each section has a header followed by the actual data. For example:
Header1
x,y,z
x,y,z
x,y,z
Header2
a,b,c
a,b,c
a,b,c
I want to read through the file in one pass and do different things with the data present under each section. I know how to parse the data, but I’m having trouble figuring out how to code the logic for “Do this until hitting Header2, then do something else until Header3, etc.”
I’m using ruby, and I haven’t really come across any examples of doing this. Any suggestions?
At the simplest you could do something like this:
If the number of headers becomes too high, you can start tracking headers with an integer: