- 'dd:hh:mm:ss'
- 'hh:mm:ss'
- 'mm:ss'
- 'hh:mm'
- Any of the first three formats, with up to nine S characters to indicate fractional second digits, such as 'hh:mm:ss.SSSS'
Unable to detect datetime or duration data using readtimetable with a seconds index
조회 수: 12 (최근 30일)
이전 댓글 표시
Here is a toy example of my problem:
% Create a timetable with a seconds index
data = timetable(seconds(1:3)', randn(3,1), randn(3,1))
writetimetable(data, "test.csv")
data_in = readtimetable("test.csv")
Output:
data =
3×2 timetable
Time Var1 Var2
_____ ________ _________
1 sec -0.10224 0.31286
2 sec -0.24145 -0.86488
3 sec 0.31921 -0.030051
Error using readtimetable (line 190)
Unable to detect datetime or duration data in file '/Users/username/test.csv' for row times.
The content of the CSV is as follows:
Time,Var1,Var2
1 sec,-0.225584402271252,0.0325574641649735
2 sec,1.11735613881447,0.552527021112224
3 sec,-1.08906429505224,1.10061021788087
For comparison, this works fine:
% Create a timetable with a regular datetime index
dt = datetime({'2015-12-18 08:00:00';'2015-12-18 08:01:00';'2015-12-18 08:02:00'});
data = timetable(dt, randn(3,1), randn(3,1));
writetimetable(data, "test.csv")
data_in = readtimetable("test.csv")
댓글 수: 0
채택된 답변
Cris LaPierre
2021년 4월 13일
편집: Cris LaPierre
2021년 4월 13일
The issue appears to be that seconds get written in a format that MATLAB cannot read back in. The only supported input formats for durations are
The values are written with the units: 1 sec
For now, I would recommend creating and saving the timetable using one of the recognized formats.
% Create a timetable with a seconds index
data = timetable(duration(zeros(3,1),zeros(3,1),(1:3)'), randn(3,1), randn(3,1))
writetimetable(data, "test.csv");
data_in = readtimetable("test.csv")
댓글 수: 7
Jiri Hajek
2022년 6월 27일
I just met with this same issue in R2022, update 2. Hopefully the incompatibility between writetimetable and readtimetable will be reslved in a future MATLAB update...
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Timetables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!