Best way to parse text file
Afficher commentaires plus anciens
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 commentaires
per isakson
le 7 Avr 2015
Modifié(e) : per isakson
le 7 Avr 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
le 8 Avr 2015
Jesse Program
le 10 Avr 2015
per isakson
le 10 Avr 2015
Modifié(e) : per isakson
le 10 Avr 2015
Yes, but there was a major "issue" and no time to fix it. Now, I have posted a new code.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur String dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!