Delimiter for csv format
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I did a matlab code for transform csv files to organized table in a xls file (by delimiter). The Problem:
Error using textscan
Mismatch between file and format string.
Trouble reading 'Numeric' field from file (row number 1, field number 2) ==>
Xavi,3237.531009,2083.298925,501.542962,404.082872,162.895678,85.710573,121,1,89,7,8,26.156520,4.672901\n
Error in GPS_import_AFA (line 41)
dataArray = textscan(fileID, formatSpec, endRow(1)-startRow(1)+1, 'Delimiter', delimiter, 'EmptyValue'
,NaN,'HeaderLines', startRow(1)-1, 'ReturnOnError', false);
Error in delimitar_dados_gps_csv (line 28)
data=GPS_import_AFA(Filename,2);
0 comentarios
Respuestas (1)
Jan
el 9 de Ag. de 2017
It is a strange method to read a file line by line by frewind-ing it in each iteration. It would be much cheapter to import the file at once and perfomr the sorting afterwards. Note that the disk access is 1000 times slower than accessing the data in the RAM.
The
formatSpec = '%f%f%f%f%f%f%f%*s%*s%*s%[^\n\r]';
and the data:
20170730,Xavi,3237.531009,2083.298925,501.542962,404.082872,162.895678,85.710573,121,1,89,7,8,26.156520,4.672901
do not match: As the error message tells clearly already, the 2nd input is not a number. What about:
formatSpec = '%f%s%f%f%f%f%f%*s%*s%*s%[^\n\r]';
0 comentarios
Ver también
Categorías
Más información sobre Text Files en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!