What causes readtable() to read .csv files into a table with cell arrays instead of a table with numeric values
Ältere Kommentare anzeigen
Hello matlab world, I am using the function readtable() to read in a .csv file. This file has some columns that are strings, and other columns that are numeric. For some reason, on about half the files that I read in it reads the files as tables with cell arrays (as shown in the attached picture), and the other half of the time it reads them correctly, where some columns are strings and some are numeric.
I have tried checking the input files for any non numeric values in the numeric columns. One conclusion: I know it does this when the data is not perfectly nxm, but has half a row filled in somewhere, but this is not the issue
Thanks in advance andrew
What other reasons could cause readtable() to grab my data as such?
1 Kommentar
per isakson
am 9 Feb. 2015
Bearbeitet: per isakson
am 10 Feb. 2015
- "shown in the attached picture"   missing
- probably something differs between the groups of files
- why not upload (paper-clip-button) one file with and one without the problem
Antworten (1)
Peter Perkins
am 10 Feb. 2015
1 Stimme
Most likely you have (what are supposed to be) numeric columns in the file that contain strings like 'NA' or '.', which readtable sees and then assumes the column must be strings. Perhaps you need to specify TreatAsEmpty.
In any case, if you know the format of the file, your best bet is to specify the format to readtable.
Hope this helps.
Kategorien
Mehr zu Tables finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!