Re: How to read the data like this? [message #36532] |
Thu, 02 October 2003 02:24 |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
wang_likun@yahoo.com wrote:
> Thanks a lot, it works.
>
> Likun~
What did read_ascii use as fill_value ?
is it 0.0 ?
Reimar
>
> Wonko@wonkology.org (Alex Schuster) wrote in message news:<8up3jj2ed8B@wonkology.org>...
>
>> wang_likun@yahoo.com (wang_likun@yahoo.com) writes:
>>
>>
>>> Hi,all:
>>
>>
>>
>>> Could you give me help to read the data with fixed column and rows but
>>> containing some missing data? Something like this:
>>
>> [...]
>>
>> You can do this easily using READ_ASCII. Create a template before
>> this, using fixed width:
>>
>> mytemplate = ascii_template( filename )
>> result = read_ascii( filename, template=mytemplate )
>>
>> If you need to do this more often, I suggest to either SAVE the
>> template to a file, or create this structure in your program on the
>> fly.
>>
>> Alex
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
============================================================ =======
|
|
|
Re: How to read the data like this? [message #36535 is a reply to message #36532] |
Wed, 01 October 2003 16:05  |
wang_likun
Messages: 2 Registered: October 2003
|
Junior Member |
|
|
Thanks a lot, it works.
Likun~
Wonko@wonkology.org (Alex Schuster) wrote in message news:<8up3jj2ed8B@wonkology.org>...
> wang_likun@yahoo.com (wang_likun@yahoo.com) writes:
>
>> Hi,all:
>
>> Could you give me help to read the data with fixed column and rows but
>> containing some missing data? Something like this:
>
> [...]
>
> You can do this easily using READ_ASCII. Create a template before
> this, using fixed width:
>
> mytemplate = ascii_template( filename )
> result = read_ascii( filename, template=mytemplate )
>
> If you need to do this more often, I suggest to either SAVE the
> template to a file, or create this structure in your program on the
> fly.
>
> Alex
|
|
|
|
Re: How to read the data like this? [message #36546 is a reply to message #36545] |
Tue, 30 September 2003 04:48  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Dear Likun,
I would suggest to do convert first missing data blanks into fill_Value
and read this data then again.
e.g.
file='test.dat'
n=file_lines(file)
txt=make_array(n,/string)
openr,lun,/get_lun,file
readf,lun,txt
free_lun,lun
;separator=string(9b); if it is tab delimited
separator=' ' ; if it is two blanks
fill_value=999.0
for i=0,n-1 do
txt[i]=replace_string(txt[i],separator+separator,separator+n 2s(fill_value)+separator)
for i=0,n-1 do
txt[i]=replace_string(txt[i],separator+separator,separator+n 2s(fill_value)+separator)
openw,lun,/get_lun,file+'.txt',width=200
printf,lun,txt
free_lun,lun
x=read_data_file(file+'.txt')
The routines replace_string, n2s and read_data_file you'll find in our
library.
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
regards
Reimar
wang_likun@yahoo.com wrote:
> Hi,all:
>
> Could you give me help to read the data with fixed column and rows but
> containing some missing data? Something like this:
> ------------------------------------------------------------ --------------------
> 871.0 1288 -2.9 -5.5 82 2.93 300 5 281.1 289.6 281.6
> 868.0 1315 -3.5 -8.5 68 2.33 286 5 280.8 287.6 281.2
> 850.0 1478 -2.3 -7.2 69 2.63 200 7 283.7 291.4 284.2
> 836.0 1610 -1.5 -7.5 64 2.61 188 9 285.9 293.7 286.4
> 816.2 1800 -3.0 -8.0 69 2.58 170 12 286.3 293.9 286.7
> 785.8 2100 -5.4 -8.8 77 2.52 175 17 286.8 294.3 287.2
> 780.0 2158 -5.9 -8.9 79 2.51 176 18 286.9 294.4 287.4
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
============================================================ =======
|
|
|