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

Home » Public Forums » archive » Re: about READ_ASCII format and PRINT a double array
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: about READ_ASCII format and PRINT a double array [message #61186] Wed, 09 July 2008 08:07 Go to next message
Spon is currently offline  Spon
Messages: 178
Registered: September 2007
Senior Member
On Jul 9, 6:50 am, CL <lynn0...@gmail.com> wrote:
> Dear all,
>
> I have two troubles in IDL.
>
> One is about READ_ASCII,
> is there any method to read the "string" from some ascii file?
> a test file is as follows,
> -------------------------
> 1 A 30.123123123
> 2 B 40.123123123
> -------------------------
> test=read_ascii('test file')
> col2=[test.field1[1,*]]
>
> IDL will try to transform the format into float.
> Is there any method to read that as a string?
>
> The other trouble is about PRINT
> as the test file above, if I want to print it out,
> col3=[test.field1[2,*]]
> it won't print the "30.123123123" correctly even though
> I set the print format to "D."
> And because the numbers are in an array, I cannot add "d" as
> "30.123123123d."
> Is there any method to print such array correctly?
>
> Thanks a lot!
> CL

You can select to read in this column as double precision by creating
a template with ASCII_TEMPLATE.

MyTemplate = ASCII_TEMPLATE('file.dat')
- at step 3, click on the appropriate field and choose double
precision

Data = READ_ASCII('file.dat', TEMPLATE = MyTemplate)

Regards,
Chris
Re: about READ_ASCII format and PRINT a double array [message #61204 is a reply to message #61186] Wed, 09 July 2008 09:41 Go to previous message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Jul 9, 12:50 am, CL <lynn0...@gmail.com> wrote:
> Dear all,
>
> I have two troubles in IDL.
>
> One is about READ_ASCII,
> is there any method to read the "string" from some ascii file?
> a test file is as follows,
> -------------------------
> 1     A    30.123123123
> 2     B    40.123123123
> -------------------------
> test=read_ascii('test file')
> col2=[test.field1[1,*]]
>
> IDL will try to transform the format into float.
> Is there any method to read that as a string?
>
> The other trouble is about PRINT
> as the test file above, if I want to print it out,
> col3=[test.field1[2,*]]
> it won't print the "30.123123123" correctly even though
> I set the print format to "D."
> And because the numbers are in an array, I cannot add "d" as
> "30.123123123d."
> Is there any method to print such array correctly?
>
> Thanks a lot!
> CL

You can use the ascii_template() function to make a template then pass
this as a keyword to read_ascii.
Re: about READ_ASCII format and PRINT a double array [message #61207 is a reply to message #61186] Wed, 09 July 2008 09:28 Go to previous message
Camilo Mejia is currently offline  Camilo Mejia
Messages: 4
Registered: July 2008
Junior Member
On Jul 9, 1:16 am, CL <lynn0...@gmail.com> wrote:
> Dear all,
>
> I have two troubles in IDL.
>
> One is about READ_ASCII,
> is there any method to read the "string" from some ascii file?
> a test file is as follows,
> -------------------------
> 1 A 30.123123123
> 2 B 40.123123123
> -------------------------
> test=read_ascii('test file')
> col2=[test.field1[1,*]]
>
> IDL will try to transform the format into float.
> Is there any method to read that as a string?
>
> The other trouble is about PRINT
> as the test file above, if I want to print it out,
> col3=[test.field1[2,*]]
> it won't print the "30.123123123" correctly even though
> I set the print format to "D."
> And because the numbers are in an array, I cannot add "d" as
> "30.123123123d."
> Is there any method to print such array correctly?
>
> Thanks a lot!
> CL

Hey, have you try
openr,2,'test file'
s=' '
readf,2,s
this read the file line by line.
then extract the part of the string 's' that you need.
cheers
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: not so IDL related... Command line auto-feed
Next Topic: Re: Mapping image into a polar-square coordinate

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

Current Time: Wed Oct 08 18:41:08 PDT 2025

Total time taken to generate the page: 0.00464 seconds