Best way to parse text file
Ältere Kommentare anzeigen
I am trying to write some code to parse large text files of weather data. The formatting of the text file is broken into blocks, by state. The data I'm working with is here
Within each block (state), the .txt file formatting is consistent and should be fairly straight forward to parse. However, each block has an inconsistent number of rows (varying amount of reporting weather stations across states, and time) it not clear to me that each block is delimited from one another. I'm trying to get ultimately arrive at an N x 3 matrix, with columns for state, county, and total snowfall.
I'm not sure which functions are best for this purpose. Can someone point me in the right direction? I don't know where to start....
Thanks
5 Kommentare
per isakson
am 7 Apr. 2015
Bearbeitet: per isakson
am 7 Apr. 2015
- where does BLMA1 belong? It's StnID and not all stations have a StnID value. That makes things a "little" more complicated.
- the columns of the data block are separated by one or more spaces?
- are the widths of the columns known?

Jesse Program
am 8 Apr. 2015
Jesse Program
am 10 Apr. 2015
per isakson
am 10 Apr. 2015
Bearbeitet: per isakson
am 10 Apr. 2015
Yes, but there was a major "issue" and no time to fix it. Now, I have posted a new code.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Data Import and Export finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!