Hello guys,
I have a text file contains GNSS processed meansurements with time resolution (5-min) [every 300 sec), the date fromat are (YY:DOY:SSSSS) format, and its type is string in the file, I tired to read it with readtable but I got error message
T = readtable(filename, 'Format','%{yy:dayofyear:sssss}D %f');
the error message is:
Unable to read the DATETIME data with the format 'yy:dayofyear:sssss'. If the data is not a time
I attached the file ( the file conatins 5 rows as a header)
any suggestion on how to read a date in this format??

 Akzeptierte Antwort

Yazan
Yazan am 4 Jul. 2021

0 Stimmen

Try this:
readtable(filename, 'Format', '%{uu:DDD:SSSS}D %f')

6 Kommentare

Steven Lord
Steven Lord am 4 Jul. 2021
More generally look at the section for the Format property on the documentation page for the datetime function. The tables in that section give the letter identifiers that you can use to build up valid values for the Format property of a datetime or valid values for the 'Format' and 'InputFormat' name-value inputs to the datetime function. When you pass a Format into readtable to read a date and time it passes that Format to datetime as the 'InputFormat'.
DDD is specifically "Day of the year using three digits". Depending on how your data is formatted you may want to use DD or even D.
sorry for replying late. I want to creat if statement related to the second part of the time vector in Col1 in my table, I need something like this
if sssss<200000
add some values
end
but I don't know how to put the condition based on the (seconds) only in my time-vector. any suggestions??
Thanks
Call second on the datetime.
dt = datetime('now', 'Format', 'dd.MMM.yyyy HH:mm:ss.SSSS')
dt = datetime
05.Jul.2021 23:44:25.1622
s = second(dt)
s = 25.1622
Ebtesam Farid
Ebtesam Farid am 5 Jul. 2021
Thanks for help :)
I have another question, please. my data points are every 300 sec, so I have the second field from 00000 till 86200 sec (which reprents 24 hours of the day), and I have some files that don't start from 000 second, instead it may start from (60,000 sec or 72,000 sec). Now I need to creat if statement that has condition to say that if the seconds don't start from 000 sec, fill this data points with zero.
I succed with the data points which not ended with 86200
I wrote
T = readtable(filename, 'Format', '%{uu:DDD:SSSS}D %f');
time = T.Var1;
datapoints = T.Var2;
sec = second(time);
if sec<0.8620
A = zeros(288-length(datapoints),:);
datapoints_1 = [datapoints; A];
elseif sec~=0.00000
datapoints_1 = [A; datapoints];
end
but I get an error.
any help. Thanks
This
readtable(filename, 'Format', '%{uu:DDD:SSSS}D %f')
can't possibly be right. S is fractional seconds. It's parsing those timestamps completely wrong. Maybe if you do something like this
>> d = datetime('2021:135:12345',"InputFormat","uuuu:DDD:SSSSS","Format","uuuu:DD HH:mm:ss.SSSSSSSSS")
d =
datetime
2021:135 00:00:00.123450000
>> s = d.Second
s =
0.12345
>> d = dateshift(d,'start','day') + seconds(1e5*s)
d =
datetime
2021:135 03:25:45.000000000
>> second(d,"secondofday")
ans =
12345
but there is no datetime format that will parse or display "second of day". And then this
sssss<200000
isn't going to be right, again you'd need second(d,"secondofday").

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by