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

Home » Public Forums » archive » Re: Reading in a non-rectangular array
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 in a non-rectangular array [message #50893] Wed, 25 October 2006 12:42 Go to next message
willettk is currently offline  willettk
Messages: 20
Registered: October 2006
Junior Member
Thanks for the tip. I haven't used strmid and strsplit before, but they
seem suited to this sort of problem.

On Oct 25, 11:52 am, "Jean H." <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
wrote:
> Hi,
> Try to read each line as a string, then split this string using strSplit
> with the keywork Preserve_Null set. Then you can build your 6*n array,
> filling the location having a null string value with a flag value...
>
> Jean
>
> wille...@gmail.com wrote:
>> G'day,
>
>> I'm trying to read in a data table to IDL that is (gasp)
>> non-rectangular (thanks very much to the astronomers involved). The
>> data is in an ASCII file, but certain cells will simply be blank if
>> there was no data for that particular value (so out of 6 columns, any
>> given row might have 0-6 actual values). Reading this into IDL, though,
>> doesn't seem to work according to Hoyle. This is what I have tried (and
>> received):
>
>> ___________
>
>> fname = 'table1.dat'
>> openr, lun1, fname, /get_lun
>> nlines = file_lines(fname)
>> data = fltarr(6, nlines)
>> readf, lun1, data
>
>> % READF: Input conversion error. Unit: 100
>> File: /Users/willettk/table1
>> % Execution halted at: $MAIN$
>
>> ___________
>
>> Any ideas that might help me read the data? Many thanks, if so.
Re: Reading in a non-rectangular array [message #50896 is a reply to message #50893] Wed, 25 October 2006 10:52 Go to previous messageGo to next message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
Hi,
Try to read each line as a string, then split this string using strSplit
with the keywork Preserve_Null set. Then you can build your 6*n array,
filling the location having a null string value with a flag value...

Jean


willettk@gmail.com wrote:
> G'day,
>
> I'm trying to read in a data table to IDL that is (gasp)
> non-rectangular (thanks very much to the astronomers involved). The
> data is in an ASCII file, but certain cells will simply be blank if
> there was no data for that particular value (so out of 6 columns, any
> given row might have 0-6 actual values). Reading this into IDL, though,
> doesn't seem to work according to Hoyle. This is what I have tried (and
> received):
>
> ___________
>
> fname = 'table1.dat'
> openr, lun1, fname, /get_lun
> nlines = file_lines(fname)
> data = fltarr(6, nlines)
> readf, lun1, data
>
> % READF: Input conversion error. Unit: 100
> File: /Users/willettk/table1
> % Execution halted at: $MAIN$
>
> ___________
>
> Any ideas that might help me read the data? Many thanks, if so.
>
Re: Reading in a non-rectangular array [message #50964 is a reply to message #50893] Thu, 26 October 2006 07:50 Go to previous message
Braedley is currently offline  Braedley
Messages: 57
Registered: September 2006
Member
willettk@gmail.com wrote:
> Thanks for the tip. I haven't used strmid and strsplit before, but they
> seem suited to this sort of problem.
>
> On Oct 25, 11:52 am, "Jean H." <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
> wrote:
>> Hi,
>> Try to read each line as a string, then split this string using strSplit
>> with the keywork Preserve_Null set. Then you can build your 6*n array,
>> filling the location having a null string value with a flag value...
>>
>> Jean
>>
>> wille...@gmail.com wrote:
>>> G'day,
>>
>>> I'm trying to read in a data table to IDL that is (gasp)
>>> non-rectangular (thanks very much to the astronomers involved). The
>>> data is in an ASCII file, but certain cells will simply be blank if
>>> there was no data for that particular value (so out of 6 columns, any
>>> given row might have 0-6 actual values). Reading this into IDL, though,
>>> doesn't seem to work according to Hoyle. This is what I have tried (and
>>> received):
>>
>>> ___________
>>
>>> fname = 'table1.dat'
>>> openr, lun1, fname, /get_lun
>>> nlines = file_lines(fname)
>>> data = fltarr(6, nlines)
>>> readf, lun1, data
>>
>>> % READF: Input conversion error. Unit: 100
>>> File: /Users/willettk/table1
>>> % Execution halted at: $MAIN$
>>
>>> ___________
>>
>>> Any ideas that might help me read the data? Many thanks, if so.

There are other methods involving read_ASCII and ASCII_template, but
if the afforementioned method works for you, use that first.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Add a Dot on top of a letter
Next Topic: Mac 64-bit

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

Current Time: Wed Oct 08 19:42:20 PDT 2025

Total time taken to generate the page: 0.00639 seconds