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

Home » Public Forums » archive » Re: A (too?) simple question about importing data
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: A (too?) simple question about importing data [message #20444 is a reply to message #20433] Thu, 22 June 2000 00:00 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
q4668057@bonsai.fernuni-hagen.de (Michael Spranger) writes:
> Hi,
> another beginner's question, this time about reading data:
> I want to read data from ASCII files into a structure. The data look
> as follows:
>
> YYYY MM DD HH II SSSSS PPPPPP LLLLLLL KKK RRR
> 0330 00 00 00 00 00000 50.60 03.40 000 0.0 USGS_EU_Catalogue
>
> the structure, type, and length of variables are always the same, only
> the the order might change and some data might be missing. The last
> row (without header) contains comments only.

It's a beginner's *and* advanced user's question. My suggestion is to
try TRANSREAD available from my web page. It attempts to make it easy
to read lots of data from a file. [ To get the formatting right I
suggest using the /DEBUG option. ]

I made a file called test.dat with the following lines:

YYYY MM DD HH II SSSSS PPPPPP LLLLLLL KKK RRR
0330 00 00 00 00 00000 50.60 03.40 000 0.0 USGS_EU_Catalogue
0340 00 00 00 00 00000 124.56 03.40 000 0.0 Test line 1
0350 00 00 00 00 00000 789.01 03.40 000 0.0 Test line 2

And then executed the following commands:

IDL> yyyy = 0L & mm = 0L & dd = 0L & hh = 0L & ii = 0L & sssss = 0L
IDL> pppppp = 0D & lllllll = 0D & kkk = 0L & rrr = 0D & ccc = ''
IDL> transread, unit, yyyy, mm, dd, hh, ii, sssss, pppppp, lllllll, kkk, $
rrr, ccc, format='(I5,I3,I3,I3,I3,I6,D7,D8,I4,D4,A0)', file='test.dat'
IDL> print, yyyy
330 340 350

The first two lines establish the types of each variable -- I used the
column headers you provided. The third line is the actual invocation
of TRANSREAD. The format keyword is vital, and may take some
experimentation. Note that lines that don't match the format are
skipped automatically, you can define comment characters, and you can
specify start/stop "cues" to enable/disable parsing.

Craig
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
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: IDL memory allocation limitation
Next Topic: Re: MINIMUM DISTANCE BETWEEN TWO CURVES

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

Current Time: Sat Oct 11 04:26:04 PDT 2025

Total time taken to generate the page: 2.00139 seconds