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

Home » Public Forums » archive » READF: Input conversion error.
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
READF: Input conversion error. [message #91312] Mon, 29 June 2015 08:41 Go to next message
Priyadarsini Sivaraj is currently offline  Priyadarsini Sivaraj
Messages: 15
Registered: June 2015
Junior Member
Hello Everyone..

I have 15 simple ASCII files, which have to be read and the details of it are to be stored in a structure called ROI. The fields of the structure are,
NumROI-vector
Name-String
Color- 3 element vector
NumPoints-integer
Records-integer
Points- Two dimensional vector.

I tried reading them all in a loop by using,

FOR i=1,15 DO BEGIN
filename=[str,STRTRIM(i,2),ext]
file=[filelocation,filename]
Trial_ROI_Read,file

In the procedure, I tried doing this,

PRO Trial_ROI_Read, file


p =MAKE_ARRAY(5,198,value=1)
ROIs = CREATE_STRUCT('NumROI',[1],'Name','a','Color','1,1,1','NumPo ints',[1],'Records',[1],'Points',p[*,*])
OPENR, lun1,file, /GET_LUN
header = STRARR(12)
READF, lun1, header
ROIs.NumROI=STRMID(header(3),18)
ROIs.Name=STRMID(header(9),12)
ROIs.NumPoints=STRMID(header(11),13)
ROIs.Color=STRMID(header(10),17)


points = [id , x, y, lat, lon]
WHILE ~EOF(lun1) DO BEGIN

READF, lun1, id, x, y, lat, lon
pt = [id,x,y,lat,lon]
;print, pt
points = [points , pt]

ENDWHILE

points= REFORM(points , [ 5 , 198 ])

But I am not able to open the file and the following error pops up:
OPENR: Expression must be a scalar or 1 element array in this context: FILENAME.

Is there any efficient way to do this..??Please do help me out..I am not well versed with IDL.
Re: READF: Input conversion error. [message #91313 is a reply to message #91312] Mon, 29 June 2015 08:44 Go to previous messageGo to next message
Priyadarsini Sivaraj is currently offline  Priyadarsini Sivaraj
Messages: 15
Registered: June 2015
Junior Member
On Monday, 29 June 2015 11:41:32 UTC-4, Priyadarsini Sivaraj wrote:
> Hello Everyone..
>
> I have 15 simple ASCII files, which have to be read and the details of it are to be stored in a structure called ROI. The fields of the structure are,
> NumROI-vector
> Name-String
> Color- 3 element vector
> NumPoints-integer
> Records-integer
> Points- Two dimensional vector.
>
> I tried reading them all in a loop by using,
>
> FOR i=1,15 DO BEGIN
> filename=[str,STRTRIM(i,2),ext]
> file=[filelocation,filename]
> Trial_ROI_Read,file
>
> In the procedure, I tried doing this,
>
> PRO Trial_ROI_Read, file
>
>
> p =MAKE_ARRAY(5,198,value=1)
> ROIs = CREATE_STRUCT('NumROI',[1],'Name','a','Color','1,1,1','NumPo ints',[1],'Records',[1],'Points',p[*,*])
> OPENR, lun1,file, /GET_LUN
> header = STRARR(12)
> READF, lun1, header
> ROIs.NumROI=STRMID(header(3),18)
> ROIs.Name=STRMID(header(9),12)
> ROIs.NumPoints=STRMID(header(11),13)
> ROIs.Color=STRMID(header(10),17)
>
>
> points = [id , x, y, lat, lon]
> WHILE ~EOF(lun1) DO BEGIN
>
> READF, lun1, id, x, y, lat, lon
> pt = [id,x,y,lat,lon]
> ;print, pt
> points = [points , pt]
>
> ENDWHILE
>
> points= REFORM(points , [ 5 , 198 ])
>
> But I am not able to open the file and the following error pops up:
> OPENR: Expression must be a scalar or 1 element array in this context: FILENAME.
>
> Is there any efficient way to do this..??Please do help me out..I am not well versed with IDL.

Sry..The subject is OPENR: Expression must be a scalar or 1 element array in this context: FILENAME.
Re: READF: Input conversion error. [message #91314 is a reply to message #91313] Mon, 29 June 2015 08:49 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Priyadarsini Sivaraj writes:

> Sry..The subject is OPENR: Expression must be a scalar or 1 element array in this context: FILENAME.

Two things are wrong. Arrays in IDL are zero-based, so array indices go
from 0 to n-1, not from 1 to n, as you have it here. And, string
concatenation happens with a plus sign. You have:

file=[filelocation,filename]

Making "file" a two-element array (when it should be a scalar). You
probably want something like this:

file = filelocation + filename

Or, perhaps this:

file = filelocaton + PathSep() + filename

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: READF: Input conversion error. [message #91316 is a reply to message #91314] Mon, 29 June 2015 08:58 Go to previous messageGo to next message
Priyadarsini Sivaraj is currently offline  Priyadarsini Sivaraj
Messages: 15
Registered: June 2015
Junior Member
On Monday, 29 June 2015 11:49:58 UTC-4, David Fanning wrote:
> Priyadarsini Sivaraj writes:
>
>> Sry..The subject is OPENR: Expression must be a scalar or 1 element array in this context: FILENAME.
>
> Two things are wrong. Arrays in IDL are zero-based, so array indices go
> from 0 to n-1, not from 1 to n, as you have it here. And, string
> concatenation happens with a plus sign. You have:
>
> file=[filelocation,filename]
>
> Making "file" a two-element array (when it should be a scalar). You
> probably want something like this:
>
> file = filelocation + filename
>
> Or, perhaps this:
>
> file = filelocaton + PathSep() + filename
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

Thank you so much sir!
But another error pops out saying,
READF: Input conversion error. Unit: 105,
How can I handle this..?
Re: READF: Input conversion error. [message #91317 is a reply to message #91316] Mon, 29 June 2015 09:15 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Priyadarsini Sivaraj writes:

> Thank you so much sir!
> But another error pops out saying,
> READF: Input conversion error. Unit: 105,
> How can I handle this..?

Without you giving us information about where errors are occurring in
your program, we can only guess. Normally, errors like this occur when
you tell IDL to read a number is there is only a string there, or visa
versa.

Find the line that is causing you the error (it is in your error
message), then stop the code there and examine what is in the file at
that location and what you are trying to read (the HELP command will be
useful to you). You are making assumptions about what is happening that
aren't true. Make sure all your data types are matching. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: READF: Input conversion error. [message #91318 is a reply to message #91317] Mon, 29 June 2015 09:22 Go to previous messageGo to next message
Priyadarsini Sivaraj is currently offline  Priyadarsini Sivaraj
Messages: 15
Registered: June 2015
Junior Member
On Monday, 29 June 2015 12:15:02 UTC-4, David Fanning wrote:
> Priyadarsini Sivaraj writes:
>
>> Thank you so much sir!
>> But another error pops out saying,
>> READF: Input conversion error. Unit: 105,
>> How can I handle this..?
>
> Without you giving us information about where errors are occurring in
> your program, we can only guess. Normally, errors like this occur when
> you tell IDL to read a number is there is only a string there, or visa
> versa.
>
> Find the line that is causing you the error (it is in your error
> message), then stop the code there and examine what is in the file at
> that location and what you are trying to read (the HELP command will be
> useful to you). You are making assumptions about what is happening that
> aren't true. Make sure all your data types are matching. :-)
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")


There are two READF statements in my code.This error occurs at the line:
READF, lun1, id, x, y, lat, lon
Here, I try to read the text into variables namely: id, x, y, lat, lon.
Is there anything that I can do to rectify this error..?
Re: READF: Input conversion error. [message #91319 is a reply to message #91318] Mon, 29 June 2015 09:28 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Priyadarsini Sivaraj writes:

> There are two READF statements in my code.This error occurs at the
line:
> READF, lun1, id, x, y, lat, lon
> Here, I try to read the text into variables namely: id, x, y, lat, lon.
> Is there anything that I can do to rectify this error..?

Yes, follow my suggestions and let us know what happens. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: READF: Input conversion error. [message #91320 is a reply to message #91319] Mon, 29 June 2015 09:32 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> Yes, follow my suggestions and let us know what happens. :-)

Here is another hint. Open one of your data files up in a text editor.
What line do you suppose you are trying to read when the error occurs?

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: READF: Input conversion error. [message #91321 is a reply to message #91312] Mon, 29 June 2015 10:36 Go to previous messageGo to next message
Priyadarsini Sivaraj is currently offline  Priyadarsini Sivaraj
Messages: 15
Registered: June 2015
Junior Member
On Monday, 29 June 2015 11:41:32 UTC-4, Priyadarsini Sivaraj wrote:
> Hello Everyone..
>
> I have 15 simple ASCII files, which have to be read and the details of it are to be stored in a structure called ROI. The fields of the structure are,
> NumROI-vector
> Name-String
> Color- 3 element vector
> NumPoints-integer
> Records-integer
> Points- Two dimensional vector.
>
> I tried reading them all in a loop by using,
>
> FOR i=1,15 DO BEGIN
> filename=[str,STRTRIM(i,2),ext]
> file=[filelocation,filename]
> Trial_ROI_Read,file
>
> In the procedure, I tried doing this,
>
> PRO Trial_ROI_Read, file
>
>
> p =MAKE_ARRAY(5,198,value=1)
> ROIs = CREATE_STRUCT('NumROI',[1],'Name','a','Color','1,1,1','NumPo ints',[1],'Records',[1],'Points',p[*,*])
> OPENR, lun1,file, /GET_LUN
> header = STRARR(12)
> READF, lun1, header
> ROIs.NumROI=STRMID(header(3),18)
> ROIs.Name=STRMID(header(9),12)
> ROIs.NumPoints=STRMID(header(11),13)
> ROIs.Color=STRMID(header(10),17)
>
>
> points = [id , x, y, lat, lon]
> WHILE ~EOF(lun1) DO BEGIN
>
> READF, lun1, id, x, y, lat, lon
> pt = [id,x,y,lat,lon]
> ;print, pt
> points = [points , pt]
>
> ENDWHILE
>
> points= REFORM(points , [ 5 , 198 ])
>
> But I am not able to open the file and the following error pops up:
> OPENR: Expression must be a scalar or 1 element array in this context: FILENAME.
>
> Is there any efficient way to do this..??Please do help me out..I am not well versed with IDL.
This is my data file:


;2013_IEEE_GRSS_DF_Contest_Samples_TR


; Number of ROIs: 15
; File Dimension: 1905 x 349
; X=1 , Y=1 -> Upper-Left Corner
; X=1905, Y=349 -> Lower-Right Corner


; ROI name: grass_healthy
; ROI rgb value: {0, 205, 0}
; ROI npts: 198
; ID X Y Lat Lon
1 769 7 29.724995542787 -95.349772592660
2 768 7 29.724995084106 -95.349798420654
3 772 7 29.724996918802 -95.349695108676
4 771 7 29.724996460135 -95.349720936671

1 769 7 29.724995542787 -95.349772592660- This is the line where error occurs.
Re: READF: Input conversion error. [message #91322 is a reply to message #91321] Mon, 29 June 2015 10:40 Go to previous messageGo to next message
Priyadarsini Sivaraj is currently offline  Priyadarsini Sivaraj
Messages: 15
Registered: June 2015
Junior Member
On Monday, 29 June 2015 13:36:40 UTC-4, Priyadarsini Sivaraj wrote:
> On Monday, 29 June 2015 11:41:32 UTC-4, Priyadarsini Sivaraj wrote:
>> Hello Everyone..
>>
>> I have 15 simple ASCII files, which have to be read and the details of it are to be stored in a structure called ROI. The fields of the structure are,
>> NumROI-vector
>> Name-String
>> Color- 3 element vector
>> NumPoints-integer
>> Records-integer
>> Points- Two dimensional vector.
>>
>> I tried reading them all in a loop by using,
>>
>> FOR i=1,15 DO BEGIN
>> filename=[str,STRTRIM(i,2),ext]
>> file=[filelocation,filename]
>> Trial_ROI_Read,file
>>
>> In the procedure, I tried doing this,
>>
>> PRO Trial_ROI_Read, file
>>
>>
>> p =MAKE_ARRAY(5,198,value=1)
>> ROIs = CREATE_STRUCT('NumROI',[1],'Name','a','Color','1,1,1','NumPo ints',[1],'Records',[1],'Points',p[*,*])
>> OPENR, lun1,file, /GET_LUN
>> header = STRARR(12)
>> READF, lun1, header
>> ROIs.NumROI=STRMID(header(3),18)
>> ROIs.Name=STRMID(header(9),12)
>> ROIs.NumPoints=STRMID(header(11),13)
>> ROIs.Color=STRMID(header(10),17)
>>
>>
>> points = [id , x, y, lat, lon]
>> WHILE ~EOF(lun1) DO BEGIN
>>
>> READF, lun1, id, x, y, lat, lon
>> pt = [id,x,y,lat,lon]
>> ;print, pt
>> points = [points , pt]
>>
>> ENDWHILE
>>
>> points= REFORM(points , [ 5 , 198 ])
>>
>> But I am not able to open the file and the following error pops up:
>> OPENR: Expression must be a scalar or 1 element array in this context: FILENAME.
>>
>> Is there any efficient way to do this..??Please do help me out..I am not well versed with IDL.
> This is my data file:
>
>
> ;2013_IEEE_GRSS_DF_Contest_Samples_TR
>
>
> ; Number of ROIs: 15
> ; File Dimension: 1905 x 349
> ; X=1 , Y=1 -> Upper-Left Corner
> ; X=1905, Y=349 -> Lower-Right Corner
>
>
> ; ROI name: grass_healthy
> ; ROI rgb value: {0, 205, 0}
> ; ROI npts: 198
> ; ID X Y Lat Lon
> 1 769 7 29.724995542787 -95.349772592660
> 2 768 7 29.724995084106 -95.349798420654
> 3 772 7 29.724996918802 -95.349695108676
> 4 771 7 29.724996460135 -95.349720936671
>
> 1 769 7 29.724995542787 -95.349772592660- This is the line where error occurs.

I have to read these values into separate variables namely,lun1, id, x, y, lat, lon. Earlier I had used a READF statement as follows:
READF, lun1, header
This is done to separate out the header and store the information present in it separately.
Re: READF: Input conversion error. [message #91323 is a reply to message #91322] Mon, 29 June 2015 10:49 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Priyadarsini Sivaraj writes:

> I have to read these values into separate variables namely,lun1, id, x, y, lat, lon. Earlier I had used a READF statement as follows:
> READF, lun1, header
> This is done to separate out the header and store the information present in it separately.

Why don't you put a breakpoint in your code at the line that is causing
you trouble. Instead of using the READF statement that is causing the
error, just read that line of the data file. Something like this:

line = ""
ReadF, lun1, line

Print it out:

Print, line

Is that the line you are trying to read into the variables id, x, y,
lat, and lon?

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: READF: Input conversion error. [message #91324 is a reply to message #91323] Mon, 29 June 2015 11:00 Go to previous messageGo to next message
Priyadarsini Sivaraj is currently offline  Priyadarsini Sivaraj
Messages: 15
Registered: June 2015
Junior Member
On Monday, 29 June 2015 13:49:13 UTC-4, David Fanning wrote:
> Priyadarsini Sivaraj writes:
>
>> I have to read these values into separate variables namely,lun1, id, x, y, lat, lon. Earlier I had used a READF statement as follows:
>> READF, lun1, header
>> This is done to separate out the header and store the information present in it separately.
>
> Why don't you put a breakpoint in your code at the line that is causing
> you trouble. Instead of using the READF statement that is causing the
> error, just read that line of the data file. Something like this:
>
> line = ""
> ReadF, lun1, line
>
> Print it out:
>
> Print, line
>
> Is that the line you are trying to read into the variables id, x, y,
> lat, and lon?
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

This is the output for the print statement.
ID X Y Lat Lon

Yes, I understand the fault.Is there any way that I can skip this line..?
Re: READF: Input conversion error. [message #91325 is a reply to message #91324] Mon, 29 June 2015 11:05 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Priyadarsini Sivaraj writes:

>
> This is the output for the print statement.
> ID X Y Lat Lon
>
> Yes, I understand the fault.Is there any way that I can skip this line..?

Well, let me put it this way: you skipped the first 12 lines
successfully. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: READF: Input conversion error. [message #91326 is a reply to message #91325] Mon, 29 June 2015 11:26 Go to previous messageGo to next message
Priyadarsini Sivaraj is currently offline  Priyadarsini Sivaraj
Messages: 15
Registered: June 2015
Junior Member
On Monday, 29 June 2015 14:05:23 UTC-4, David Fanning wrote:
> Priyadarsini Sivaraj writes:
>
>>
>> This is the output for the print statement.
>> ID X Y Lat Lon
>>
>> Yes, I understand the fault.Is there any way that I can skip this line..?
>
> Well, let me put it this way: you skipped the first 12 lines
> successfully. :-)
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Oh well..That is the trick..!!!Thank you sir..!!1
Re: READF: Input conversion error. [message #91373 is a reply to message #91326] Tue, 07 July 2015 08:28 Go to previous messageGo to next message
Priyadarsini Sivaraj is currently offline  Priyadarsini Sivaraj
Messages: 15
Registered: June 2015
Junior Member
On Monday, 29 June 2015 14:26:34 UTC-4, Priyadarsini Sivaraj wrote:
> On Monday, 29 June 2015 14:05:23 UTC-4, David Fanning wrote:
>> Priyadarsini Sivaraj writes:
>>
>>>
>>> This is the output for the print statement.
>>> ID X Y Lat Lon
>>>
>>> Yes, I understand the fault.Is there any way that I can skip this line..?
>>
>> Well, let me put it this way: you skipped the first 12 lines
>> successfully. :-)
>>
>> Cheers,
>>
>> David
>> --
>> David Fanning, Ph.D.
>> Fanning Software Consulting, Inc.
>> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
> Oh well..That is the trick..!!!Thank you sir..!!1

Hello everyone..

I have a problem again with the code above..All of a sudden, I keep getting this error,
'READF: End of file encountered.'

At the line,

'READF, lun1, id, x, y, lat, lon'

in the loop,

WHILE ~EOF(lun1) DO BEGIN
READF, lun1, id, x, y, lat, lon
pt = [id,x,y,lat,lon]
points = [points , pt]
ENDWHILE

What can be done to overcome this error?Please do help me.
Re: READF: Input conversion error. [message #91374 is a reply to message #91373] Tue, 07 July 2015 08:39 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Priyadarsini Sivaraj writes:

> I have a problem again with the code above..All of a sudden, I keep getting this error,
> 'READF: End of file encountered.'
>
> At the line,
>
> 'READF, lun1, id, x, y, lat, lon'
>
> in the loop,
>
> WHILE ~EOF(lun1) DO BEGIN
> READF, lun1, id, x, y, lat, lon
> pt = [id,x,y,lat,lon]
> points = [points , pt]
> ENDWHILE
>
> What can be done to overcome this error?Please do help me.

I would say make sure the file contains what you *think* it contains.
You are probably mistaken. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: READF: Input conversion error. [message #91375 is a reply to message #91374] Tue, 07 July 2015 08:53 Go to previous messageGo to next message
Priyadarsini Sivaraj is currently offline  Priyadarsini Sivaraj
Messages: 15
Registered: June 2015
Junior Member
On Tuesday, 7 July 2015 11:39:52 UTC-4, David Fanning wrote:
> Priyadarsini Sivaraj writes:
>
>> I have a problem again with the code above..All of a sudden, I keep getting this error,
>> 'READF: End of file encountered.'
>>
>> At the line,
>>
>> 'READF, lun1, id, x, y, lat, lon'
>>
>> in the loop,
>>
>> WHILE ~EOF(lun1) DO BEGIN
>> READF, lun1, id, x, y, lat, lon
>> pt = [id,x,y,lat,lon]
>> points = [points , pt]
>> ENDWHILE
>>
>> What can be done to overcome this error?Please do help me.
>
> I would say make sure the file contains what you *think* it contains.
> You are probably mistaken. :-)
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

Yes.My file does contain all the necessary information. The exact code snippet has worked earlier.Now, I am not able to deduce what could be the fault. :-(
Re: READF: Input conversion error. [message #91376 is a reply to message #91375] Tue, 07 July 2015 08:57 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Priyadarsini Sivaraj writes:

> Yes.My file does contain all the necessary information. The exact code snippet has worked earlier.Now, I am not able to deduce what could be the fault. :-(

I'm not convinced. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: READF: Input conversion error. [message #91379 is a reply to message #91375] Tue, 07 July 2015 09:43 Go to previous messageGo to next message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Hello,

On 07/07/15 11:53, Priyadarsini Sivaraj wrote:
> On Tuesday, 7 July 2015 11:39:52 UTC-4, David Fanning wrote:
>> Priyadarsini Sivaraj writes:
>>
>>> I have a problem again with the code above..All of a sudden, I keep getting this error,
>>> 'READF: End of file encountered.'
>>>
>>> At the line,
>>>
>>> 'READF, lun1, id, x, y, lat, lon'
>>>
>>> in the loop,
>>>
>>> WHILE ~EOF(lun1) DO BEGIN
>>> READF, lun1, id, x, y, lat, lon
>>> pt = [id,x,y,lat,lon]
>>> points = [points , pt]
>>> ENDWHILE
>>>
>>> What can be done to overcome this error?Please do help me.
>>
>> I would say make sure the file contains what you *think* it contains.
>> You are probably mistaken. :-)
>>
>> Cheers,
>>
>> David
>> --
>> David Fanning, Ph.D.
>> Fanning Software Consulting, Inc.
>> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
>
> Yes.My file does contain all the necessary information. The exact
> codesnippet has worked earlier.Now, I am not able to deduce what could be
> the fault. :-(

If the code worked before then the only other thing that has changed is
the file itself, no?

The error message you are getting is quite clear - you're trying to read
past the end of the file.

You could try looking at using the ON_ERROR (or setting up an exception
handler with CATCH) command to print out the values of id, x, y, lat,
and lon *after* the error has occurred to see if they are what they
should be.

Also, you could print out the values after they are read successfully,
too. It might be a lot of output to screen, but it can't hurt while
you're debugging.

cheers,

paulv
Re: READF: Input conversion error. [message #91381 is a reply to message #91375] Tue, 07 July 2015 10:03 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Priyadarsini Sivaraj writes:

> Yes.My file does contain all the necessary information. The exact code snippet has worked earlier.Now, I am not able to deduce what could be the fault. :-(

Is there possibly an extra blank line at the end of this particular
file?

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: READF: Input conversion error. [message #91389 is a reply to message #91381] Wed, 08 July 2015 06:07 Go to previous messageGo to next message
Priyadarsini Sivaraj is currently offline  Priyadarsini Sivaraj
Messages: 15
Registered: June 2015
Junior Member
On Tuesday, 7 July 2015 13:03:05 UTC-4, David Fanning wrote:
> Priyadarsini Sivaraj writes:
>
>> Yes.My file does contain all the necessary information. The exact code snippet has worked earlier.Now, I am not able to deduce what could be the fault. :-(
>
> Is there possibly an extra blank line at the end of this particular
> file?
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

Oh yes sir. There was extra space and now its working..Thanks a million sir.:-)
Re: READF: Input conversion error. [message #91390 is a reply to message #91379] Wed, 08 July 2015 06:08 Go to previous message
Priyadarsini Sivaraj is currently offline  Priyadarsini Sivaraj
Messages: 15
Registered: June 2015
Junior Member
On Tuesday, 7 July 2015 12:43:43 UTC-4, Paul van Delst wrote:
> Hello,
>
> On 07/07/15 11:53, Priyadarsini Sivaraj wrote:
>> On Tuesday, 7 July 2015 11:39:52 UTC-4, David Fanning wrote:
>>> Priyadarsini Sivaraj writes:
>>>
>>>> I have a problem again with the code above..All of a sudden, I keep getting this error,
>>>> 'READF: End of file encountered.'
>>>>
>>>> At the line,
>>>>
>>>> 'READF, lun1, id, x, y, lat, lon'
>>>>
>>>> in the loop,
>>>>
>>>> WHILE ~EOF(lun1) DO BEGIN
>>>> READF, lun1, id, x, y, lat, lon
>>>> pt = [id,x,y,lat,lon]
>>>> points = [points , pt]
>>>> ENDWHILE
>>>>
>>>> What can be done to overcome this error?Please do help me.
>>>
>>> I would say make sure the file contains what you *think* it contains.
>>> You are probably mistaken. :-)
>>>
>>> Cheers,
>>>
>>> David
>>> --
>>> David Fanning, Ph.D.
>>> Fanning Software Consulting, Inc.
>>> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>>> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
>>
>> Yes.My file does contain all the necessary information. The exact
>> codesnippet has worked earlier.Now, I am not able to deduce what could be
>> the fault. :-(
>
> If the code worked before then the only other thing that has changed is
> the file itself, no?
>
> The error message you are getting is quite clear - you're trying to read
> past the end of the file.
>
> You could try looking at using the ON_ERROR (or setting up an exception
> handler with CATCH) command to print out the values of id, x, y, lat,
> and lon *after* the error has occurred to see if they are what they
> should be.
>
> Also, you could print out the values after they are read successfully,
> too. It might be a lot of output to screen, but it can't hurt while
> you're debugging.
>
> cheers,
>
> paulv

Yes.The new file had extra space at the end.I failed to notice it.Now its working.Thank you..
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: cw_form widget offset
Next Topic: READ, adn get data into an array from LARGE SIZE FILES

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

Current Time: Wed Oct 08 09:10:41 PDT 2025

Total time taken to generate the page: 0.00578 seconds