Delimiter for csv format
7 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Jan
2017 年 8 月 9 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Text Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!