Problems With readtable. Convert string data in datetime with milissecond precision.
7 ビュー (過去 30 日間)
古いコメントを表示
Hi! I try to read the csv file attached, with this command:
t = readtable('Test2.csv','Format','%{HH:mm:ss;SSS}D,%f%f%f%f')
But returns the error:
"Unable to read the DATETIME data with the format 'HH:mm:ss;SSS'. If the data is not a time, use %q to get text data."
My First column is in correct format. How i fix this? I'm using the R2017b version
Thanks a lot!
1 件のコメント
Stephen23
2017 年 11 月 15 日
In case anyone is interested, here are the first four rows of the file:
Time,GVPos,VlvLimCmd,SpeedCtrlSP,Speed,PIDOut
12:38:06.865,6.021393,8,102.5,102.412323,6.069856
12:38:06.915,6.021393,8,102.5,102.408577,6.076125
12:38:06.965,6.021393,8,102.5,102.400078,6.082932
回答 (3 件)
Greg
2017 年 11 月 15 日
You aren't accounting for your header row:
Time,GVPos,VlvLimCmd,SpeedCtrlSP,Speed,PIDOut
"Time" is clearly not in the datetime format.
Assuming you've handled that separately, your first column is NOT in the correct format:
12:38:06.865,6.021393,8,102.5,102.412323,6.069856
That is clearly a period "." not a semicolon ";" between seconds and fractional seconds.
Thank you for posting your actual code (and not a billion lines of useless fluff around it), as well as your actual test data. This makes for an amazingly simple and unambiguous question, and makes it extremely easy and desirable for us to want to help you.
0 件のコメント
KL
2017 年 11 月 15 日
Try this,
data = readtable('Teste2.csv');
data.Time = datetime(datevec(data.Time),'Format','HH:mm:ss.SSS');
0 件のコメント
Jeremy Hughes
2017 年 11 月 15 日
Your time seems to have a decimal separator of '.' it's the semicolon that's the issue.
t = readtable('Test2.csv','Format','%{HH:mm:ss.SSS}D%f%f%f%f')
Jeremy
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!