CSV file import with timestamp
Ältere Kommentare anzeigen
I have csv data in the following format
value, timestamp, id
1.48,"2011-02-07 11:27:18+11",1
which I would like to import into Matlab so that I can look at the differences in successive time stamps. So I would like to convert the time of minutes to seconds and plot the difference. What is the best way to import this data?
Akzeptierte Antwort
Weitere Antworten (1)
Kye Taylor
am 29 Mär. 2012
The assignment
fmt = %f "%u-%u-%u %u:%u:%u+%u" %u
should be
fmt = '%f "%u-%u-%u %u:%u:%u+%u" %u'
(notice the single quotes). To make the unpacking of output from textscan slightly easier, you could define fmt as below. Note the fopen and fclose statements before and after invoking textscan.
fmt = '%f%q%f';
fid = fopen('yourFileName.csv');
nowInMatlab = textscan(fid,fmt,'delimiter',',');
fclose(fid);
Kategorien
Mehr zu Data Import and Analysis finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!