What causes readtable() to read .csv files into a table with cell arrays instead of a table with numeric values
이전 댓글 표시
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
per isakson
2015년 2월 9일
편집: per isakson
2015년 2월 10일
- "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
답변 (1개)
Peter Perkins
2015년 2월 10일
1 개 추천
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.
카테고리
도움말 센터 및 File Exchange에서 Large Files and Big Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!