Re: Loading ASCII data into an array [message #45801] |
Sat, 15 October 2005 11:55 |
noekains@gmail.com
Messages: 3 Registered: October 2005
|
Junior Member |
|
|
Hi Reimar,
Thanks a lot for your help- indeed there were a few comment lines in
the file. I actually deleted them manually- I suppose there is a
keyword to skip them, like 'data_start' in the read procedures?
Best wishes,
Noah
|
|
|
Re: Loading ASCII data into an array [message #45802 is a reply to message #45801] |
Sat, 15 October 2005 08:18  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
noekains@gmail.com wrote:
> Hi,
> I'm a new IDL-convert and I am still struggling a bit with some of the
> features.
> I would like to load a large - 26 columns, 41063 rows - ASCII file into
> a 26 columns 41063 rows array in order to be able to access individual
> elements afterwards. I've been trying to use the read_ascii procedure
> to do this, using
>
> data=read_ascii('aqu1.asc', data_start=13)
>
> but this then defines an anonymous structure with 26 fields. When I'm
> trying to access an element of the data array other than [0,0], I get
> the message "Attempt to subscript DATA with <INT ( 8)> is
> out of range."
Hi Noah
try help,data[0].(0) vor the first element of first column
read_ascii returnes an arrayed structure because by this each column could
have a different type
the whole first column is
help,data.(0)
> I've also tried creating a template with the ascii_template command,
> but I get the same problem. Another thing I tried was to create a [26,
> 41063] floating points array, then using
>
> OpenR, lun, 'aqu1.asc', /Get_Lun
> ReadF, lun, data
> Free_Lun, lun
>
>
> but I then get the message
>
> READF: Input conversion error. Unit: 100, File: C:\RSI\IDL61\aqu1.asc
Do you have probably a comment line before the array of data begins? If so
you need only to overread this line and it goes well.
>
> Is there anyway to simply load the ASCII data into an array, in the
> same way as you get simple arrays when you load image data with
> procedures such as read_jpeg or read_dicom ?
Yes,
see above.
An alternative could be our read_data_file from our library at
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
cheers
Reimar
|
|
|