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

Home » Public Forums » archive » Read irregular data problem
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
Read irregular data problem [message #92164] Thu, 22 October 2015 09:38 Go to next message
d.poreh is currently offline  d.poreh
Messages: 406
Registered: October 2007
Senior Member
Folks,
Hi,
I have a data like this:

DESCRIPTION=Unknown Point Feature
ELEVATION=1.379
14.2899550000,41.1586500000,1.379

DESCRIPTION=Unknown Point Feature
ELEVATION=-1.635
14.2819110000,41.1528830000,-1.635

DESCRIPTION=Unknown Point Feature
ELEVATION=1.379
14.2899550000,41.1586500000,1.379

DESCRIPTION=Unknown Point Feature
ELEVATION=-1.635
14.2819110000,41.1528830000,-1.635

DESCRIPTION=Unknown Point Feature
ELEVATION=-0.805
14.2815830000,41.1521640000,-0.805

......
and i just need to extract the lines like:

14.2899550000,41.1586500000,1.379
14.2819110000,41.1528830000,-1.635
...

i did somethings like this:
file=dialog_pickfile()
data = (read_ascii(file,delim="|")).field1[0:2,*]

but the result is bad:
NaN NaN 14.2900

Can someone please give me some hints?
Thanks for any kind of help in advance,
Cheers,
Dave
Re: Read irregular data problem [message #92173 is a reply to message #92164] Fri, 23 October 2015 04:33 Go to previous messageGo to next message
greg.addr is currently offline  greg.addr
Messages: 160
Registered: May 2007
Senior Member
Try this...

pro tmp_poreh,filename

n_lines=file_lines(filename)
s=strarr(n_lines)
openr,lun,filename,/get_lun
readf,lun,s
free_lun,lun

q=where(strpos(s,"ELEVATION") ne -1)
print,transpose(s[q+1])

data=fltarr(3,n_elements(q))
reads,s[q+1],data

print,data
end

IDL> tmp_poreh,"d:\tmp\poreh.txt"
14.2899550000,41.1586500000,1.379
14.2819110000,41.1528830000,-1.635
14.2899550000,41.1586500000,1.379
14.2819110000,41.1528830000,-1.635
14.2815830000,41.1521640000,-0.805
14.2900 41.1586 1.37900
14.2819 41.1529 -1.63500
14.2900 41.1586 1.37900
14.2819 41.1529 -1.63500
14.2816 41.1522 -0.805000

cheers,
Greg
Re: Read irregular data problem [message #92177 is a reply to message #92164] Fri, 23 October 2015 07:29 Go to previous message
d.poreh is currently offline  d.poreh
Messages: 406
Registered: October 2007
Senior Member
On Thursday, October 22, 2015 at 8:08:49 PM UTC+3:30, dave poreh wrote:
> Folks,
> Hi,
> I have a data like this:
>
> DESCRIPTION=Unknown Point Feature
> ELEVATION=1.379
> 14.2899550000,41.1586500000,1.379
>
> DESCRIPTION=Unknown Point Feature
> ELEVATION=-1.635
> 14.2819110000,41.1528830000,-1.635
>
> DESCRIPTION=Unknown Point Feature
> ELEVATION=1.379
> 14.2899550000,41.1586500000,1.379
>
> DESCRIPTION=Unknown Point Feature
> ELEVATION=-1.635
> 14.2819110000,41.1528830000,-1.635
>
> DESCRIPTION=Unknown Point Feature
> ELEVATION=-0.805
> 14.2815830000,41.1521640000,-0.805
>
> ......
> and i just need to extract the lines like:
>
> 14.2899550000,41.1586500000,1.379
> 14.2819110000,41.1528830000,-1.635
> ...
>
> i did somethings like this:
> file=dialog_pickfile()
> data = (read_ascii(file,delim="|")).field1[0:2,*]
>
> but the result is bad:
> NaN NaN 14.2900
>
> Can someone please give me some hints?
> Thanks for any kind of help in advance,
> Cheers,
> Dave
Thanks Greg :), works like a charm:)
Cheers,
Dave
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Writing 2 arrays of a different type into one text file
Next Topic: Re: MATRIX LOGARITHM (and EXPONENTIAL)

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

Current Time: Wed Oct 08 09:16:13 PDT 2025

Total time taken to generate the page: 0.02017 seconds