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 #62328 is a reply to message #62325] Fri, 05 September 2008 12:34 Go to previous messageGo to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
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".
[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:20:55 PDT 2025

Total time taken to generate the page: 0.15247 seconds