MATLAB Answers

0

Mismatch between file and format character vector but the CSV file contains only numerics?

nb4532 님이 질문을 제출함. 18 Jun 2019
최근 활동 per isakson 님이 편집함. 19 Jun 2019
I am receiving this error when trying to read a csv file that appears to contain only numeric values:
error.PNG
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

로그인 to comment.

태그

제품


릴리스

R2018b

답변 수: 1

Answer by per isakson
on 18 Jun 2019
Edited by per isakson
on 19 Jun 2019
 Accepted Answer

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

There is the inherent problem that double-quoted numbers are to be considered character strings in csv files, not numeric.

로그인 to comment.



Translated by