how to read mixed date and data
조회 수: 2 (최근 30일)
이전 댓글 표시
How to read this data file:
2020/11/15 07:30:55 27.50 124
2020/11/15 07:40:55 27.63 114
2020/11/15 07:50:55 27.71 95
댓글 수: 0
채택된 답변
Jeremy Hughes
2021년 9월 27일
I made some corrections in the comments above, but this is how I would do this more robustly using partial detection with detectImportOptions.
filename = "example.txt";
opts = detectImportOptions(filename,"Delimiter","\t");
opts = setvaropts(opts,1,"Type","datetime","InputFormat","uuuu/MM/dd HH:mm:ss");
T = readtable(filename,opts)
추가 답변 (1개)
the cyclist
2021년 9월 24일
You can specify the input formating if needed.
댓글 수: 4
Jeremy Hughes
2021년 9월 27일
If you're using format, there are issues with your format in both cases: mm cannot be both months and minutes, you want MM.
Also, you probably want the second part as duration if you're parsing these as separate fields.
try this: formatSpec = '%{yyyy/MM/dd}D{hh:mm:ss}T%f%f'
But I like your first approach better:
delimiter = '\t'; %no space
formatSpec = '%{yyyy/MM/dd HH:mm:ss}D%f%f'
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!