limited csvread troubled by NAN not within limits
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Juri Maibaum
le 20 Avr 2018
Modifié(e) : Juri Maibaum
le 20 Avr 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 commentaires
Réponse acceptée
Walter Roberson
le 20 Avr 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 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!