comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: reading files with date- and time - columns
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: reading files with date- and time - columns [message #23906] Mon, 26 February 2001 11:14
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"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
------------------------------------------------------------ --------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Change default value of system variable?
Next Topic: significant figures function?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 20:06:34 PDT 2025

Total time taken to generate the page: 0.40340 seconds