reading a complex text file
3 views (last 30 days)
Show older comments
Hi, I want to read a text file exactly as below, the file consists of 3 sections, that I copied the first lines from each section below. as you can see the 3rd section starts with a text line and this one line is the only string type of data in the text file. I cannot just delete it since this file is going to be read and written (after some change) in an iterative manner. I appreciate it if someone can help me with this.
1
0.00
1 5 4 180
2 5 4 180
3 5 3 180
1 1 32 5 4 1 4 0 0 0
4 1 1 3 7062 6493 16015
1 2 32 5 4 1 6493 0 0 0
6493 1 2 3 16015 4 7062
=======Two Way Stop Signs/Yield Signs Below =======
75 2 2
750 75 6186 75
76 75 6182 75
381 2 1
0 Comments
Accepted Answer
Walter Roberson
on 19 Jun 2011
Looks like at least 5 sections to me.
Please indicate which parts are a fixed number of lines, and which parts can be repeated indefinitely.
The lines that end with 0 -- are those always exactly 10 fields, and will those lines always start with 1 ? Will the lines with 7 fields strictly alternate with the lines with 10 fields? Is 7 a fixed number of fields or does it vary with the data?
In the third section, is every line always 3 or 4 fields?
How do you want the data broken up for further use?
For the third section, should some particular "filler" value be used to indicate that the 4th value is not present?
Is that 0.00 certain to be the only floating point number?
Portions of the file appear to be fixed width fields. Are those portions defined to be fixed width fields? If so, then can an empty field appear in the middle of the line or only at the end of the line?
3 Comments
More Answers (0)
See Also
Categories
Find more on Standard File Formats in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!