Matlab: read time stamp in a loop -
i need read several hundred .csv
data files, each of them fixed number of columns , variable number of rows of type:
'%s %d %d %d %u:%u %d %s %s %s %s'
which corresponds to:
text1 2014 2 1 1:56 -2 text2 text3 text4 text5
i need correctly import timestamp distinguishing minutes , hours , store them in 2 separate columns.
part of program:
directory_name = 'c:\deutsche_bank\'; filepattern = [directory_name, filesep, '*.csv']; files = dir(directory_name); fileindex = find(~[files.isdir]); fileindex = fileindex'; df = 3:size(fileindex, 1)+2; %start 3 filename = files(df).name; tempfullname = [directory_name, filesep, filename]; fmt = '%s %d %d %d %u:%u %d %s %s %s %s'; fid = fopen('tempfullname'); mytimestamp = textscan(fid, fmt, 'delimiter', ','); fclose(fid); ... more matlab data analysis end
unfortunately program output in mytimestamp
set of empty cells, whereas if specify directly file:
fid = fopen('c:\deutsche_bank\myfile.csv');
i obtain nice mytimestamp
data correctly stored.
it seems loop producing problem, not know do.
you need change fid = fopen('tempfullname')
fid = fopen(tempfullname)
Comments
Post a Comment