Read irregular data problem [message #92164] |
Thu, 22 October 2015 09:38  |
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   |
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  |
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
|
|
|