[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: reading files with date- and time - columns
"Zeschke" <zeschke@bessy.de> writes:
> Hallo,
>
> I have files for example in such a format:
>
> File : s.log
> ;DATE TIME n x VALUES
> 23.01.2001 08:39:41 21 21.4 0
> 23.01.2001 08:40:16 21 21.3 0
> 23.01.2001 08:40:51 21 21.3 0
> 23.01.2001 08:41:26 21 21.4 0
>
> or such a format:
>
> ;DATE TIME n x VALUES
> 2/23/2001 08:39:41.643 34.660
> 2/23/2001 08:49:41.456 34.960
There are tons of ways to do this in IDL. In principle the best way
to do this is read the data with a structure. This is what my
TRANSREAD does internally. Here is how I would do it, first
initializing the data, and then reading it.
mm = 0 & dd = 0 & yyyy = 0 & hh = 0 & mi = 0 & ss = 0 & nn = 0 & x = 0. & i = 0
openr, unit, 'myfile.dat'
transread, data, mm, dd, yyyy, hh, mi, ss, nn, x, i, comment=';', /debug, $
format='(I2,1X,I2,1X,I4,1X,I2,1X,I2,1X,I2,1X,I0,1X,F0,1X,I0)'
; mm . dd . yy hh : mi : ss nn val zero
I've never had much success using explicit quoted style format codes
for *reading* data, so I tend to use the "X" code instead for skipping
dead characters. The use of the /DEBUG keyword is crucial for the
initial phases to be sure your format code is working.
After you get this, then there is the (trivial) matter of assembling
the component data into a single date, presumably with CALDATE, etc.
Craig
TRANSREAD found at http://cow.physics.wisc.edu/~craigm/idl/idl.html
--
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------