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

Home » Public Forums » archive » problem using strsplit
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: problem using strsplit [message #33638 is a reply to message #33523] Mon, 13 January 2003 01:28 Go to previous messageGo to previous message
briana is currently offline  briana
Messages: 2
Registered: January 2003
Junior Member
Thanks for the ideas - It is useful see the different ways it can be done.
I now have a working program.

Reimar Bauer <R.Bauer@fz-juelich.de> wrote in message news:<avq2un$9dn1$1@zam602.zam.kfa-juelich.de>...
> Brian wrote:
>
>> I am relatively new to IDL and am probably missing something very
>> obvious. I am reading in an ascii tab separated file into a string
>> array. I know how many rows the file will contain but not how many
>> columns hence the string array.
>> I then try to use strsplit to separate all the columns but have an
>> error - it seems that the columns are not seen as separate.
>> Code and example file below.
>>
>> Any ideas would be useful,
>> Thanks
>> Brian Appleby
>> Geophysicist
>> BrianA@Zetica.com
>>
>
> Dear Brian
>
> You can use our file reading routine,
> It determines itselfs almost all parameter for file reading of an array
> orientaded data file, with or without some comments in the header or at the
> end.
>
>
> http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/download/read_data_file.tar.gz
> idl binary
> http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_source/idl _html/dbase/download/read_data_file.sav
>
> for further routine and licensing lease have a look at
> http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
>
>
> If you don't like using these routines you can examine the number of columns
> by counting the separator.
>
> no_of_scans=5
> OPENR, lun, 'file2.txt', / GET_LUN
> rawdata=StrArr(no_of_scans)
> ReadF,lun,rawdata
> free_lun,lun
>
> line=strtrim(strcompress(rawdata[0]),2)
> ; strcompress compresses blanks to one blank
> ; strim ,2 trailing blanks are removed
>
> ix=where(byte(line) eq 32b,n)
> n_columns=n+1
>
>
> data=make_array(/long,value=-999,no_of_scans,n_columns)
> reads,rawdata,data
> ; reads is doing the thing you like to do by strsplit I believe
>
>
> In principle this is what read_data_file did, there is a bit more
> source included to find comments at the beginning or ending so the number of
> data lines could be internal calculated and
> there is some source to determine or use the type of the numbers,
>
> regards
>
> Reimar
>
>>
>> pro test_ascii_reader
>> ;setup some variable values to allow easy alteration if needed later
>> no_of_scans=1000
>> max_traces=1000
>>
>> ; open and read any ascii file with data/headers on single lines into
>> ; a string array to be split later depending on type of data
>> OPENR, lun, 'file2.txt', / GET_LUN
>> rawdata=StrArr(no_of_scans)
>> Point_Lun, lun, 0
>> ReadF,lun,rawdata
>> help,rawdata
>>
>> split_columns=STRSPLIT(rawdata,' ',/EXTRACT)
>> help,split_columns
>> end
>>
>>
>>
>> file2.txt - example data
>> 65408 65408 65408 65408 65408
>> 28800 28800 28800 28800 28800
>> 32896 32896 32896 32896 32896
>> 33152 33152 33152 33152 33152
>> 33152 33152 33152 33152 33152
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: WHERE and pointers
Next Topic: Scroll bars not appearing

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

Current Time: Wed Oct 08 18:11:22 PDT 2025

Total time taken to generate the page: 0.00255 seconds