How to extract certain column of date-time data from a text file?
Show older comments
I have a .cef text file and it is a mixture of strings and data. A part of the code is as below:
% more irrelevant description on top
DEPEND_0 = time_tags__C3_CP_EDI_EGD
end_variable = kine_flag__C3_CP_EDI_EGD
! END_CEFMERGE_INCLUDE = "C3_CH_EDI_EGD_DATASET.ceh"
!
DATA_UNTIL=EOF
!
2014-12-17T20:14:24.220514Z, 109.196, 1.526, 1, 0
2014-12-17T20:14:45.373833Z, 109.315, 0.763, 1, 0
2014-12-17T20:15:21.192066Z, 108.480, 0.763, 1, 0
2014-12-17T20:15:48.907884Z, 107.527, 0.763, 1, 0
2014-12-17T20:16:26.787885Z, 107.646, 0.763, 1, 0
2014-12-17T20:16:45.387492Z, 107.169, 0.763, 1, 0
2014-12-17T20:17:04.818033Z, 106.573, 0.763, 1, 0
2014-12-17T20:17:48.323033Z, 106.454, 0.763, 1, 0
...
I hope to extract the first column of the data, which are dates in ISO 8601 format, and use it to plot a graph. To do this my code have to neglect all the description above, as well as the remaining columns.
I have thought of using dlmread, textscan, xlsread, sscanf, fopen, but since the data type is date-time and it consists of integers and strings, it is quite a challenge to me.
2014-12-17T20:14:24.220514Z
2014-12-17T20:14:45.373833Z
2014-12-17T20:15:21.192066Z
2014-12-17T20:15:48.907884Z
2014-12-17T20:16:26.787885Z
5 Comments
Orion Yoo
on 30 Jul 2019
dpb
on 1 Aug 2019
What is a .cef file?
Attach the original file itself. The extension has no bearing on the content...a text file is a text file unless it has specific other encoding, the filename and extension are just external user names that the system may (or may not) use to assign a particular application link with.
Orion Yoo
on 1 Aug 2019
dpb
on 1 Aug 2019
Just rename it, then.
I didn't realize TMW had such a parochial mindset, but just tried it and see you're correct.
Do
copyfile('test.cef','test.txt')
where substitute your filename for 'test' and then attach that file here. Should work.
Orion Yoo
on 1 Aug 2019
Accepted Answer
More Answers (0)
Categories
Find more on Text Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!