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 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Can't find the end of a text file [message #83114] Wed, 06 February 2013 11:26
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
I might convert the string to bytes and look for control characters. For example, when IDL prints a blank line, is it really blanks (32B) or is it a line feed (10b) or carriage return (13b)? Possibly your editor ignores the control characters but IDL doesn't -- just a guess. --Wayne

On Wednesday, February 6, 2013 1:30:01 PM UTC-5, kisCA wrote:
> I already try to do as you suggest: reading lines as a string but that is where the "extra" weird blank line I told you about in my first post come in ...
Re: Can't find the end of a text file [message #83119 is a reply to message #83114] Wed, 06 February 2013 10:30 Go to previous message
kisCA is currently offline  kisCA
Messages: 78
Registered: January 2011
Member
I already try to do as you suggest: reading lines as a string but that is where the "extra" weird blank line I told you about in my first post come in ...
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
  Switch to threaded view of this topic Create a new topic Submit Reply
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 13:36:53 PDT 2025

Total time taken to generate the page: 0.00621 seconds