limited csvread troubled by NAN not within limits
1 回表示 (過去 30 日間)
古いコメントを表示
When reading csvfiles (~1,000,000x7) that contain several rows and columns, I want to read in only two columns.
data = csvread(filename,3,1,[3 1 1000006 2]);
I cut of the header, so I only have numeric fields. I cut of the rest of the columns except the second and third, so I don't include the corrupted data that contains non-numeric fields ("∞\n"). Despite not including column seven I get:
"Mismatch between file and format character vector.
Trouble reading 'Numeric' field from file (row number 521343, field number 7) ==> ∞\n"
How do I prevent this error?
0 件のコメント
採用された回答
Walter Roberson
2018 年 4 月 20 日
You cannot prevent that problem as long as you use csvread. csvread permits text only in skipped row headers or skipped leading column headers. Everything else must be numeric. The code works by reading everything except the skipped header and skipped column header, and then it throws away the parts outside the range.
You will need to use textscan yourself, or xlsread (if you are using Windows and have excel installed) or readtable
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!