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

Home » Public Forums » archive » Re: Can't find the end of a text file
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: Can't find the end of a text file [message #83121 is a reply to message #83119] Wed, 06 February 2013 10:00 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
The way your code is written, IDL will try to read 7 numbers, even if it has to continue over multiple lines. So if your file has 7 numbers per line, and ends in a blank line, then IDL will give an "end of file" error, since it can't read 7 numbers in the last line.

I would read each line into string, to be sure you are reading one line at time.

--Wayne


P.S. I would suggest the following coding changes for the loop -- the most important change being subscripting with square brackets!

while ~EOF(Unit) do begin
readf,Unit,temp
data[0,count]=temp
count++
endwhile


On Wednesday, February 6, 2013 12:13:59 PM UTC-5, kisCA wrote:
> Hi there,
>
> I got a weird problem. I am trying to read a text file with a six lines header and then a number of lines that I tried to know with:
>
> count=0
>
> mxnum=7000
>
> temp=fltarr(7)
>
> data=fltarr(7,mxnum)
>
> while EOF(Unit) eq 0 do begin
>
> readf,Unit,temp
>
> data(*,count)=temp(*)
>
> count=count+1
>
> endwhile
>
> In the middle of the loop, I got this error
>
> READF: End of file encountered.
>
>
>
> The problem is solved when I delete the last empty line of the file.
>
> And by the way, when I read and print line by line there is an empty line every two lines that I don't see when I open the file with Notepad.
>
>
>
> Anyone had this problem before ?
>
>
>
> Thank you for your help
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Mean and NaNs
Next Topic: color tables and cgcolorbar

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

Current Time: Wed Oct 08 19:37:16 PDT 2025

Total time taken to generate the page: 0.00456 seconds