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

Home » Public Forums » archive » Re: Probably a really simple read_ascii quesion....
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: Probably a really simple read_ascii quesion.... [message #68147] Thu, 01 October 2009 10:51
greg.addr is currently offline  greg.addr
Messages: 160
Registered: May 2007
Senior Member
On 1 Okt., 15:59, hethomas <het...@googlemail.com> wrote:
> I am trying to read in a text file (which is in column format) using
> read_Ascii.  Most of my variables read in fine, with the exception of
> the "time" colum, where data is in HH:MM:SS format.  (IDL reads these
> in as 1.0000).  Anyone know how to get around this?
> I did try playing with ascii_template (although I don't really want to
> have to use it), but for some reason , won't work and gives me the
> error message:
> Variable is undefined: SCREEN_SIZE.
> Error occurred at: AT_WIDGET        1364 C:\RSI\IDL63\lib
> \ascii_template.pro
>                    ASCII_TEMPLATE   1690 C:\RSI\IDL63\lib
> \ascii_template.pro
>
> I have the annoying feeling that this can be answered
> straighforwardly, and I just can't see it! Thanks in advance....
>
> Helen

read_ascii is painful to use. It's simpler to use function like this:

function read_textfile,filename
n=file_lines(filename)
s=strarr(n)
openr,lun,filename,/get_lun
readf,lun,s
free_lun,lun
return,s
end

and deal with the strings yourself. For time formats, you can make use
of this for decoding:

IDL> t='12:34:26'
IDL> time=0d ;you have to declare a double in advance...
IDL> reads,t,time,format='(C(CHI,x,CMI,x,CSI))'
IDL> print,string(time,format='(C())')
Sat Jan 01 12:34:26 1

Greg
Re: Probably a really simple read_ascii quesion.... [message #68149 is a reply to message #68147] Thu, 01 October 2009 07:09 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Helen writes:

>
> I am trying to read in a text file (which is in column format) using
> read_Ascii. Most of my variables read in fine, with the exception of
> the "time" colum, where data is in HH:MM:SS format. (IDL reads these
> in as 1.0000). Anyone know how to get around this?

I've never used READ_ASCII, but I imagine you will
have to read this column in as an 8-element string
and process it later. (I'd probably use StrSplit
to separate the string into its component parts.)

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Probably a really simple read_ascii quesion....
Next Topic: Re: histogram, how to trasfer from linear bins to logarithmic bin?

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

Current Time: Wed Oct 08 19:43:11 PDT 2025

Total time taken to generate the page: 0.00499 seconds