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!