Best way to parse text file
古いコメントを表示
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 件のコメント
per isakson
2015 年 4 月 7 日
編集済み: per isakson
2015 年 4 月 7 日
- 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
2015 年 4 月 8 日
Jesse Program
2015 年 4 月 10 日
per isakson
2015 年 4 月 10 日
編集済み: per isakson
2015 年 4 月 10 日
Yes, but there was a major "issue" and no time to fix it. Now, I have posted a new code.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で String についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!