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

Home » Public Forums » archive » Slightly incorrect values using readf on a plain text file
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
Slightly incorrect values using readf on a plain text file [message #85289] Mon, 22 July 2013 11:23 Go to next message
Meg is currently offline  Meg
Messages: 7
Registered: May 2013
Junior Member
I am trying to read the columns of a text file. All of the MET values come in slightly wrong in the one's place. Does anyone have a suggestion on how to fix this problem?

Code:

openr,dat,'/users/username/desktop/dataset2.txt',/get_lun
ph2=((em2=(inc2=(error=(numpt=(ph1=(em1=((inc1=(iof = dblarr(9999)))))))))))
met= lindgen(9999)
i=0

while not eof(dat) do begin
readf,dat,c1, c2, c3, c4, c5, c6, c7, c8, c9, c10
iof(i)=c1
inc1(i)=c2
em1(i)=c3
ph1(i)=c4
numpt(i)=c5
error(i)=c6
inc2(i)=c7
em2(i)=c8
ph2(i)=c9
met(i)=c10

i=i+1
endwhile
free_lun,dat

in=where(iof ne 0 and inc1 ne 0)
iof=iof(in)
inc1=inc1(in)
em1=em1(in)
ph1=ph1(in)
numpt=numpt(in)
error=error(in)
inc2=inc2(in)
em2=em2(in)
ph2=ph2(in)
met=met(in)
Re: Slightly incorrect values using readf on a plain text file [message #85291 is a reply to message #85289] Mon, 22 July 2013 11:49 Go to previous messageGo to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
I would define your c10 variable as c10 = 0L before starting the "while" loop. By default, c10 is of type float, and so may lose precision when reading a large long integer. --Wayne

P.S. I would also be subscripting with square brackets rather than parentheses to avoid confusion later on.

On Monday, July 22, 2013 2:23:57 PM UTC-4, Meg wrote:
> I am trying to read the columns of a text file. All of the MET values come in slightly wrong in the one's place. Does anyone have a suggestion on how to fix this problem?
>
>
>
> Code:
>
>
>
> openr,dat,'/users/username/desktop/dataset2.txt',/get_lun
>
> ph2=((em2=(inc2=(error=(numpt=(ph1=(em1=((inc1=(iof = dblarr(9999)))))))))))
>
> met= lindgen(9999)
>
> i=0
>
>
>
> while not eof(dat) do begin
>
> readf,dat,c1, c2, c3, c4, c5, c6, c7, c8, c9, c10
>
> iof(i)=c1
>
> inc1(i)=c2
>
> em1(i)=c3
>
> ph1(i)=c4
>
> numpt(i)=c5
>
> error(i)=c6
>
> inc2(i)=c7
>
> em2(i)=c8
>
> ph2(i)=c9
>
> met(i)=c10
>
>
>
> i=i+1
>
> endwhile
>
> free_lun,dat
>
>
>
> in=where(iof ne 0 and inc1 ne 0)
>
> iof=iof(in)
>
> inc1=inc1(in)
>
> em1=em1(in)
>
> ph1=ph1(in)
>
> numpt=numpt(in)
>
> error=error(in)
>
> inc2=inc2(in)
>
> em2=em2(in)
>
> ph2=ph2(in)
>
> met=met(in)
Re: Slightly incorrect values using readf on a plain text file [message #85292 is a reply to message #85291] Mon, 22 July 2013 11:58 Go to previous message
Meg is currently offline  Meg
Messages: 7
Registered: May 2013
Junior Member
Problem is fixed! Thank you!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Inconsistent problem of HDF I/O
Next Topic: Re: Fatal error when opening an image file

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

Current Time: Wed Oct 08 13:48:51 PDT 2025

Total time taken to generate the page: 0.00591 seconds