I need to parse a .txt file to a .csv file. Data to be parsed looks like the following three lines over and over till the end of the file.
oklahoma-07 (rt66) 1 12345k 9876542, 4234234.5345345 -.000001234 0000.0 14135.4 0 9992 2 12345 101.8464 192.3456 00116622 202.9136 512.3361 12.543645782334 texas-15 (hwy35) 1 12345k 9876542, 4234234.5345345 -.000001234 0000.0 14135.4 0 9992 2 12345 101.8464 192.3456 00116622 202.9136 512.3361 12.543645782334
The delimiter characters above are space.
Also the source files will be from a web site I keep the information on a web site it is a .txt file displayed on the screen at the moment. E.g. looks like "http://www.example.com/listing.txt".
There could be only the first 3 lines or 90 or 144 lines of data, but the data is always in three lines then the next data set. It simply need to parse the file to the end of file.
There are always two key characters:
"1" in the second line, and "2" in the third line of the data set
And the output needs to be parsed as follows:
oklahoma-07,(rt66), 1, 12345k, 9876542, 4234234.5345345, -.000001234, 0000.0, 14135.4, 0, 9992, 2, 12345, 101.8464, 192.3456, 00116622, 202.9136, 512.3361, 12.543645782334 texas-15, (hwy35), 1, 12345k, 9876542, 4234234.5345345, -.000001234, 0000.0, 14135.4, 0, 9992, 2, 12345, 101.8464, 192.3456, 00116622, 202.9136, 512.3361, 12.543645782334
So I can view it in Excel the delimiter character should be a comma. For simplicity, I used the same numbers for each data set.
Lastly I need to save the file to a filename.csv file at a particular location e.g. C:/documents/stuff/
.
I am completely new to Python. I have seen a lot of different code samples and it has me confused.