taking input from csv file using texstcan
Show older comments
here the content of test.csv file:
Index,Arrival_Time,Creation_Time,x,y,z,User,Model,Device,gt
0,1424696633908,1424696631913248572,-5.958191,0.6880646,8.135345,a,check4,check4_1,home
1,1424696633909,1424696631918283972,-5.95224,0.6702118,8.136536,a,check4,check4_1,home
2,1424696633918,1424696631923288855,-5.9950867,0.6535491999999999,8.204376,a,check4,check4_1,home
3,1424696633919,1424696631928385290,-5.9427185,0.6761626999999999,8.128204,a,check4,check4_1,home
4,1424696633929,1424696631933420691,-5.991516000000001,0.64164734,8.135345,a,check4,check4_1,home
5,1424696633929,1424696631938456091,-5.965332,0.6297455,8.128204,a,check4,check4_1,home
6,1424696633938,1424696631943522009,-5.991516000000001,0.6356963999999999,8.16272,a,check4,check4_1,home
7,1424696633939,1424696631948496374,-5.915344,0.63093567,8.105591,a,check4,check4_1,home
8,1424696633951,1424696631953592810,-5.984375,0.6940155,8.067505,a,check4,check4_1,home
here is the code for getting the data into matrix:
fid = fopen('test.csv');
[data] = textscan(fid, ['%d %llu %llu %lf %lf %lf %s %s %s %s' '%*[^\n]'], 'delimiter', ',','CollectOutput',true);
fclose(fid);
its producing textscan Badly formed format string. As a newbee i am not able to find any solution. anyone help please??
Answers (2)
John BG
on 2 Apr 2016
0 votes
you have a few longer than 15 digits fields that mislead IMTool.
After adding some Returns, with IMTool i got this;

Try tweaking a few fields:
After removing all the '9' but one on the left, and zeroing the 0000001 IMTool imports data correctly

If you find this answer of any help solving your question, please click on the thumbs-up vote link,
thanks in advance
John
2 Comments
Md.Mobasshir Arshed
on 3 Apr 2016
John BG
on 17 Apr 2016
the following does not crash
[data] = textscan(fid, ['%d %u %u %f %f %f %s %s %s %s %s %s'],'delimiter', ',','CollectOutput',true,'HeaderLines',1);
Walter Roberson
on 17 Apr 2016
0 votes
textscan does not permit the 'l' modifier. It uses numeric suffixes, such as %u32 . See http://www.mathworks.com/help/matlab/ref/textscan.html#inputarg_formatSpec
Categories
Find more on COM Component Integration 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!