Re: ascii-template [message #44195 is a reply to message #44137] |
Sun, 22 May 2005 12:14  |
Justin[4]
Messages: 2 Registered: March 2005
|
Junior Member |
|
|
If your files are reasonably simple (space or tab delimited) I would
avoid the use of ascii_template altogether and use a structure to define
what each line looks like, replicate the line and readf it into an array.
E.g. for 4 columns (3 integers and a float) use:
line = {year:0, month:0, day:0, temperature:0.0}
num_lines = 1000 ; Could use file_lines or similar to count the lines here
data = REPLICATE(line, num_lines) ;Make array to hold data
OPENR, lun, filename, /GET_LUN
READF, lun, data ;Read in all the data
FREE_LUN, lun ;Close file
PRINT, data[100].temperature ; Print the 101st temp
Then as your file changes just change the definition of the line
structure. Of course if you have a complicated file structure you'll need
to stick with the flexibility (and complexity) of READ_ASCII.
HTH
Justin
On Wed, 18 May 2005 12:01:32 +0200, Lasse Clausen wrote:
> greetings.
> in the course of my work this format of the ascii data file changes. new
> columns appear, other columns disappear. everytime that happens i have to
> use my SAVE_ASCII_TEMPLATE function to make a whole new template which is
> annoying if the data file now contains 25 columns instead of 26 because i
> have to type in the names of the 25 columns again although they haven't
> changed.
|
|
|