Clear Filters
Clear Filters

This file format i want to extract time and Value. What should I do??

2 views (last 30 days)
date time value
3/24/2022 11:35:02.882 AM 5.3259E-3 J
3/24/2022 11:35:02.781 AM 5.7541E-3 J
3/24/2022 11:35:02.682 AM 6.4423E-3 J
3/24/2022 11:35:02.580 AM 5.8835E-3 J
3/24/2022 11:35:02.482 AM 5.8464E-3 J
3/24/2022 11:35:02.379 AM 4.6127E-3 J
3/24/2022 11:35:02.281 AM 5.3186E-3 J
3/24/2022 11:35:02.180 AM 6.6594E-3 J
3/24/2022 11:35:02.084 AM 5.7444E-3 J
3/24/2022 11:35:01.977 AM 5.2880E-3 J
3/24/2022 11:35:01.883 AM 6.2769E-3 J
3/24/2022 11:35:01.776 AM 5.9235E-3 J
3/24/2022 11:35:01.685 AM 6.0936E-3 J
3/24/2022 11:35:01.576 AM 6.2709E-3 J
3/24/2022 11:35:01.486 AM 5.9826E-3 J
3/24/2022 11:35:01.376 AM 5.6830E-3 J
3/24/2022 11:35:01.283 AM 5.0717E-3 J
3/24/2022 11:35:01.178 AM 5.0543E-3 J
3/24/2022 11:35:01.086 AM 7.0480E-3 J
3/24/2022 11:35:00.977 AM 5.6264E-3 J

Answers (2)

Akira Agata
Akira Agata on 24 Apr 2022
How about the following?
% Read and arange the data
url = 'https://jp.mathworks.com/matlabcentral/answers/uploaded_files/976045/textfile.txt';
TT = readtimetable(url,'Delimiter','\t');
TT.Properties.VariableNames = {'Value','Type'};
% Show the result
TT
TT = 599×2 timetable
Time Value Type __________________________ _________ _____ 03/24/2022 11:35:02.882 AM 0.0053259 {'J'} 03/24/2022 11:35:02.781 AM 0.0057541 {'J'} 03/24/2022 11:35:02.682 AM 0.0064423 {'J'} 03/24/2022 11:35:02.580 AM 0.0058835 {'J'} 03/24/2022 11:35:02.482 AM 0.0058464 {'J'} 03/24/2022 11:35:02.379 AM 0.0046127 {'J'} 03/24/2022 11:35:02.281 AM 0.0053186 {'J'} 03/24/2022 11:35:02.180 AM 0.0066594 {'J'} 03/24/2022 11:35:02.084 AM 0.0057444 {'J'} 03/24/2022 11:35:01.977 AM 0.005288 {'J'} 03/24/2022 11:35:01.883 AM 0.0062769 {'J'} 03/24/2022 11:35:01.776 AM 0.0059235 {'J'} 03/24/2022 11:35:01.685 AM 0.0060936 {'J'} 03/24/2022 11:35:01.576 AM 0.0062709 {'J'} 03/24/2022 11:35:01.486 AM 0.0059826 {'J'} 03/24/2022 11:35:01.376 AM 0.005683 {'J'}
  1 Comment
Subhadip Paul
Subhadip Paul on 24 Apr 2022
thank you Akira, but i want to extract the time values to millisecond order and corresponding value.

Sign in to comment.


Stephen23
Stephen23 on 24 Apr 2022
Edited: Stephen23 on 24 Apr 2022
tbl = readtable('textfile.txt','delimiter','\t')
tbl = 599×3 table
Var1 Var2 Var3 __________________________ _________ _____ 03/24/2022 11:35:02.882 AM 0.0053259 {'J'} 03/24/2022 11:35:02.781 AM 0.0057541 {'J'} 03/24/2022 11:35:02.682 AM 0.0064423 {'J'} 03/24/2022 11:35:02.580 AM 0.0058835 {'J'} 03/24/2022 11:35:02.482 AM 0.0058464 {'J'} 03/24/2022 11:35:02.379 AM 0.0046127 {'J'} 03/24/2022 11:35:02.281 AM 0.0053186 {'J'} 03/24/2022 11:35:02.180 AM 0.0066594 {'J'} 03/24/2022 11:35:02.084 AM 0.0057444 {'J'} 03/24/2022 11:35:01.977 AM 0.005288 {'J'} 03/24/2022 11:35:01.883 AM 0.0062769 {'J'} 03/24/2022 11:35:01.776 AM 0.0059235 {'J'} 03/24/2022 11:35:01.685 AM 0.0060936 {'J'} 03/24/2022 11:35:01.576 AM 0.0062709 {'J'} 03/24/2022 11:35:01.486 AM 0.0059826 {'J'} 03/24/2022 11:35:01.376 AM 0.005683 {'J'}
tod = timeofday(tbl.Var1)
tod = 599×1 duration array
11:35:02 11:35:02 11:35:02 11:35:02 11:35:02 11:35:02 11:35:02 11:35:02 11:35:02 11:35:01 11:35:01 11:35:01 11:35:01 11:35:01 11:35:01 11:35:01 11:35:01 11:35:01 11:35:01 11:35:00 11:35:00 11:35:00 11:35:00 11:35:00 11:35:00 11:35:00 11:35:00 11:35:00 11:35:00 11:34:59
val = tbl.Var2
val = 599×1
0.0053 0.0058 0.0064 0.0059 0.0058 0.0046 0.0053 0.0067 0.0057 0.0053
  3 Comments
Stephen23
Stephen23 on 24 Apr 2022
Edited: Stephen23 on 25 Apr 2022
"but i want time values to milisecond order HH:MM:SS.FFF this should be the order"
Of course you can easily change the DURATION format (note that this does not change the stored values):
tbl = readtable('textfile.txt','delimiter','\t')
tbl = 599×3 table
Var1 Var2 Var3 __________________________ _________ _____ 03/24/2022 11:35:02.882 AM 0.0053259 {'J'} 03/24/2022 11:35:02.781 AM 0.0057541 {'J'} 03/24/2022 11:35:02.682 AM 0.0064423 {'J'} 03/24/2022 11:35:02.580 AM 0.0058835 {'J'} 03/24/2022 11:35:02.482 AM 0.0058464 {'J'} 03/24/2022 11:35:02.379 AM 0.0046127 {'J'} 03/24/2022 11:35:02.281 AM 0.0053186 {'J'} 03/24/2022 11:35:02.180 AM 0.0066594 {'J'} 03/24/2022 11:35:02.084 AM 0.0057444 {'J'} 03/24/2022 11:35:01.977 AM 0.005288 {'J'} 03/24/2022 11:35:01.883 AM 0.0062769 {'J'} 03/24/2022 11:35:01.776 AM 0.0059235 {'J'} 03/24/2022 11:35:01.685 AM 0.0060936 {'J'} 03/24/2022 11:35:01.576 AM 0.0062709 {'J'} 03/24/2022 11:35:01.486 AM 0.0059826 {'J'} 03/24/2022 11:35:01.376 AM 0.005683 {'J'}
tod = timeofday(tbl.Var1);
tod.Format = 'hh:mm:ss.SSS' % <------- did you try changing the format?
tod = 599×1 duration array
11:35:02.882 11:35:02.781 11:35:02.682 11:35:02.580 11:35:02.482 11:35:02.379 11:35:02.281 11:35:02.180 11:35:02.084 11:35:01.977 11:35:01.883 11:35:01.776 11:35:01.685 11:35:01.576 11:35:01.486 11:35:01.376 11:35:01.283 11:35:01.178 11:35:01.086 11:35:00.977 11:35:00.885 11:35:00.777 11:35:00.684 11:35:00.577 11:35:00.486 11:35:00.377 11:35:00.285 11:35:00.177 11:35:00.085 11:34:59.977

Sign in to comment.

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!