Re: reading in tab-separated string data [message #79863] |
Thu, 19 April 2012 05:45 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
timbovaird@hotmail.com writes:
> The .dat file opens in excel fine but I always get "READF: End of file
> encountered." when I try to read the table back into IDL. I have a
> similar table which uses floats instead of strings and it works fine
> so I'm not sure what is causing the problem.
The problem is that READF without a format statement
starts reading a string and reads to the end of the line.
It has no way of knowing when the string ends. So,
if you are putting five of these strings on each line,
IDL is reading this in a single line. Thus, you tell
IDL to read 5 "things", it gobbles all the data up
in 1 read, and then complains to you that it encountered
the end of the file before finishing its job.
The solution will be to come up with some kind of
format statement, if possible with this data. Or,
you will have to read each line and separate that
line into individual values (with READS or StrSplit,
probably).
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|