importing csv file into matlab

2 views (last 30 days)
I am having error while using csv read for the following file.
num = csvread (FileName,2,0);
Error using dlmread (line 143)
Mismatch between file and format string.
Trouble reading 'Numeric' field from file (row number 1, field number 57) ==>
Is there a way to read the following sheet into matlab.

Accepted Answer

Walter Roberson
Walter Roberson on 11 Jan 2017
csvread() is unable to read files with text, with the possible exception of header rows and maybe leading columns of text -- definitely not text at the end of lines.
If you have R2013b or later, I suggest you use
datatab = readtable('matlab_upload.csv', 'headerlines', 1);
per isakson
per isakson on 11 Jan 2017
Edited: per isakson on 11 Jan 2017
datatab = readtable('FileName', 'headerlines', 1);
datatab = readtable( FileName, 'headerlines', 1);
FileName is the name of a string variable. The value of the variable, FileName, is the name of the file.

Sign in to comment.

More Answers (1)

halleyhit on 10 Jan 2017
I think it is because the csv file contains too many strings. csvread is to load data not string. You can use "Improt data" on your "Home" label. Also you can generate script or function in this tool.


Find more on Data Import and Export 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!