Mismatch between file and format character vector but the CSV file contains only numerics?
17 次查看(过去 30 天)
显示 更早的评论
I am receiving this error when trying to read a csv file that appears to contain only numeric values:
Could there be something wrong with the format of the values in the csv file? Each value ends in a newline, except for the last one.
0 个评论
采纳的回答
per isakson
2019-6-18
编辑:per isakson
2019-6-19
dlmread() fails to read and convert quoted digits, e.g. "123","456","789". Neither does csvread(). See Comma-separated values. On R2018b
>> dlmread('cssm.txt')
Error using dlmread (line 147)
Mismatch between file and format character vector.
Trouble reading 'Numeric' field from file (row number 1, field number 1) ==> "123","456","789"\n
>> csvread('cssm.txt')
Error using dlmread (line 147)
Mismatch between file and format character vector.
Trouble reading 'Numeric' field from file (row number 1, field number 1) ==> "123","456","789"\n
Error in csvread (line 48)
m=dlmread(filename, ',', r, c);
Proposal:
Use the interactive tool Import Data to read the data directly or create a customized function.
1 个评论
Walter Roberson
2019-6-18
There is the inherent problem that double-quoted numbers are to be considered character strings in csv files, not numeric.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!