- "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
What causes readtable() to read .csv files into a table with cell arrays instead of a table with numeric values
32 views (last 30 days)
Show older comments
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 Comment
per isakson
on 9 Feb 2015
Edited: per isakson
on 10 Feb 2015
Answers (1)
Peter Perkins
on 10 Feb 2015
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.
0 Comments
See Also
Categories
Find more on Cell Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!