[Scilab-users] How to read in date & time ?

Richard llom richard.llom at gmail.com
Wed Nov 8 14:52:53 CET 2017


Hello,
thanks for all the replies! Somehow datenum and datevec slipped thorugh my
search ... :-/

Jan's approach seems the most suitable to me, however I forget to mention
that my log file also contains some missing / empty values, e.g.
01.01.2017;06:00;419,942
01.01.2017;07:00;513,273
01.01.2017;08:00;478,268
01.01.2017;09:00;
01.01.2017;10:00;606,592
01.01.2017;11:00;
01.01.2017;12:00;594,92
01.01.2017;13:00;524,933

But I could fix this with:
[log_data, comments] =
csvRead(log_file,';',',','double',['.',';';':',';'],"/^[^0-9\-]/");

and using
log_date =
datenum(log_data(:,3),log_data(:,2),log_data(:,1),log_data(:,4),log_data(:,5),0);
mprintf('Log Start:   %d-%02d-%02d at %02d:%02d\n',datevec(log_date(1,1)));
etc...

richard


> Hello,
> Assuming you have two header lines in your files, try this:
> tt=csvRead(log_file,";",[],"double",[".",";";":",";";",",";"],[],[],2)
> tv=datenum(tt(:,3),tt(:,2),tt(:,1),tt(:,4),tt(:,5),0)
> td=datevec(tv)
> 
> Jan
> 
> On 07.11.2017 15:38, Richard llom wrote:
>> 
>> Hello,
>> I have logfiles in the following form:
>> DESC: AAA 2017
>> Datum;Zeit;kWh
>> 01.01.2017;06:00;419,942
>> 01.01.2017;07:00;513,273
>> 01.01.2017;08:00;478,268
>> 01.01.2017;09:00;711,572
>> 01.01.2017;10:00;606,592
>> 01.01.2017;11:00;594,92
>> 01.01.2017;12:00;594,92
>> 01.01.2017;13:00;524,933
>> ... 



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html



More information about the users mailing list