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

Home » Public Forums » archive » Re: Get rid of unwanted lines.
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: Get rid of unwanted lines. [message #62324 is a reply to message #62323] Fri, 05 September 2008 14:15 Go to previous messageGo to previous message
mankoff is currently offline  mankoff
Messages: 131
Registered: March 2004
Senior Member
On Sep 5, 5:07 pm, xiao <littledd...@gmail.com> wrote:
> On Sep 5, 2:34 pm, Jean H <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
> wrote:
>
>
>
>> xiao wrote:
>>> Hi~ everyone, i have some data like this:
>
>>>       1123.97      000      15.0600      000      271.850      000
>>>       000            000       000            000      000
>>> 000
>>>       1127.98      000      15.2800      000      270.650      000
>>>       000            000       000           000       000
>>> 000
>>>       1136.68      000      15.5100      000      269.300      000
>>>        000            000       000           000       000
>>> 000
>>>       1139.05      000      15.7500      000      267.860      000
>>>       000            000       000           000       000
>>> 000
>>>       000            000       000           000       000
>>> 000
>>>       000            000       000           000       000
>>> 000
>>>       000            000       000           000       000
>>> 000
>>>       1145.10      000      15.9900      000      266.410      000
>>>       1155.74      000      16.2300      000      265.010      000
>>>       1163.19      000      16.4500      000      263.700      000
>>> I want to delete these zero lines and write other lines to another
>>> file.  How can I fulfill this ?
>>> Anyone have good ideas?
>>>                       Thank you
>
>> so, do you always have 6 numbers per lines?
>
>> do something like this:
>
>> filname = 'originalFile.txt'
>> nbLines = file_lines(filename)  ;get the number of lines in the file
>> data = fltarr(nbLines) ;create an array to get all the data
>
>> openR, lun, filename, /get_lun  ;open the file
>> readf, lun, data ;get all the data
>> close,lun       ;close the file
>> free_lun,lun
>
>> ;Select the good lines, the ones that do NOT have only zeroes
>> badLines = where(data[0,*] eq 0 and data[1,*] eq 0 and data[2,*] eq 0
>> and data[3,*] eq 0 and data[4,*] eq 0 and data[5,*] eq 0, complement =
>> goodLines)
>
>> ;open and write the output!
>> openW,lun, new_fileName, /get_lun
>> printf,data[*,goodLines]
>> close,lun
>> free_lun,lun
>
>> Jean
>> PS: since you deal with float data, you might have to replace data[x,*]
>> eq 0   by  abs(data[x,0]) lt epsilon,   epsilon being a number small
>> enough to be considered as zero. Read David's Fanning website under "the
>> sky is falling".
>
> yes, it works, but another question arouse. When I have eight columns,
> after i write them to another file, these numbers are not in the same
> line.  The last two numbers are in another line like this:
>
>       964.850      0.00000      25.3800      0.00000      335.750
> 0.00000
>      0.237400      0.00000
>       964.510      0.00000      25.0400      0.00000      338.800
> 0.00000
>      0.240100      0.00000
>       964.140      0.00000      24.6500      0.00000      342.150
> 0.00000
>      0.245400      0.00000
>       963.750      0.00000      24.2800      0.00000      345.690
> 0.00000
>      0.250700      0.00000
>
> Why is that?  thx

See WIDTH keyword to OPEN command.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: weighting: irregular grid
Next Topic: Re: Matching Lats and Lons from two arrays

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

Current Time: Wed Oct 08 19:22:32 PDT 2025

Total time taken to generate the page: 0.00380 seconds