help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem reading file with time-stamps


From: CdeMills
Subject: Re: problem reading file with time-stamps
Date: Wed, 14 Dec 2011 04:07:30 -0800 (PST)

BVBA NuKey Music wrote
> 
> I'm trying to read a file with four columns which has timestamps in the
> first column:
> 
> The data is available in the file in the following format:
> Dec-13-09:46:45 21.4 +4.76442190E-01 8.135530E-06 1.553691E+00
> Dec-13-09:47:12 21.4 +4.76439120E-01 8.135839E-06 1.553726E+00
> Dec-13-09:47:39 21.4 +4.76427260E-01 8.136261E-06 1.553853E+00
> 
> first field is a timestamp then a space followed by a temperature then a
> space ...
> 
> As you can see here below, octave doesn't accept the file because of the
> timestamps,
> can anyone here help me solve this problem?
> 
> 

Hello,
I pushed yesterday a change in my dataframe package to cope with dates. The
main issue is that there are many ways to write a date, look at datestr and
strptime doc.

I guess that, in your case, you should
1) perform a line-by-line read of the file
2) split using ' ' as delimiters
3) use strptime on the first field, matching your specific format. The
result is a tm_struct, that you can further normalise with f.i strftime(%s,
the_tm_struct) to get a real number ( elapsed seconds since Jan, 1, 1970)
4) use str2num for the other fields, to convert them to real numbers

Regards

Pascal

I guess that, in your case, you should 

--
View this message in context: 
http://octave.1599824.n4.nabble.com/problem-reading-file-with-time-stamps-tp4189556p4194631.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]