Hi i am trying to read data of multiple csv files that contains numeric,text data which is delimited by commas…
format of the raw data in these csv.files is shown below.
16744C9796,96440457110,08/11/11,10:50:40,08/11/11,11:19:32,28.867,1136CC15E35,83428990517,08/11/11,11:05:37,08/11/11,11:32:00,26.383,1F40B93397476,268330551833718,08/11/11,11:05:48,08/11/11,11:32:03,26.250,121FEAF3F48,146006818632,08/11/11,11:08:53,08/11/11,11:33:53,25.000,1405FBEF422BE,70779969741502,08/11/11,11:10:15,08/11/11,11:13:48, 3.550,0A0960EACF9,689712311545,08/11/11,11:10:42,08/11/11,11:14:01, 3.308,01474118A3811,22488743032849,08/11/11,11:11:07,08/11/11,11:13:55, 2.800,0
I tried to use the following code but i am getting this error.
d = dir('*.csv'); N_File = numel(d); C = {}; for num = 1:N_File k = fullfile(d(num).name); dat = myfileread(d(num).name,num); C = [C;dat]; num=num+1; end??? Error using ==> datenum at 182DATENUM failed.Error in ==> myfileread at 8t1 = datenum(strrep(strcat(data{3},'-',data{4}),'-',' '));Caused by:Error using ==> datevec at 286Cannot parse date . *------------ The code for the above function myfileread is-----------*function outdata = myfileread(fname,k)% read from file
fid = fopen(fname);data = textscan(fid,'%s%f%s%s%s%s%f%f','delimiter',',');fclose(fid);% extract time stamps and convert to serial date numbers
t1 = datenum(strrep(strcat(data{3},'-',data{4}),'-',' '));t2 = datenum(strrep(strcat(data{5},'-',data{6}),'-',' '));% combine together into one big cell array
outdata = num2cell(k*ones(size(data{1}))),data{1},num2cell([data{2},t1,t2,data{7},data{8}])];
Thanks in advance.
Best Answer