I would like to create a structure in IDL and put the information from my ASCII file. The problem is that I have several ASCII files and always the number of columns and rows are different. For example, I have the ASCII file "data.dat" and has 50 lines and 2040 columns. I know that we can define the data structure (if we assume I have only 5 columns):
datastruct = { col1:0L, col2:0.0, col3:0.0, col4:0.0, col5:0.0}
I can read my file and then replicate the structure:
file = 'data.dat'
nrows = file_line(file) ; to estimate the number of rows
data = replicate(datastruct, nrows)
openr, lun, file, /GET_LUN
readF, lun, data
free_lun, lun
I can do: print, data.col1
or print, data.col2
and so on... but this will give me only the first 5 columns. How I can do the same but for 2040 columns and also when we don't know in advance the number of columns in the file.
The real data file contains fluxes of several stars observed in different days with respective errors. The table has does not have a header.
Days Flux1 Err1 Flux2 Err2 Flux3 Err3..............Flux2040 Err2040
Thanks for your help!