limited csvread troubled by NAN not within limits
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Juri Maibaum
am 20 Apr. 2018
Bearbeitet: Juri Maibaum
am 20 Apr. 2018
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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 20 Apr. 2018
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
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!