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

Home » Public Forums » archive » Re: Reading in a string 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: Reading in a string file [message #39176] Wed, 28 April 2004 07:24
Ken Knapp is currently offline  Ken Knapp
Messages: 14
Registered: April 2003
Junior Member
Jonathan Greenberg wrote:
> Any hints on how to read a file which is in CSV form where each entry is a
> text string:
>
SNIP
> For numerical data I usually do a array = READ_ASCII(filename,delimiter=",")
> And then array=array.(0) so I can have it in a normal array format. For
> this data, however, I get an array of NaN

How about:
s=' '
readf,unit,s
array = strsplit(s,',',/extr)

maybe?
-Ken

--
***** to reply remove the _REMOVE_ *****

Ken Knapp Ken.Knapp@_REMOVE_noaa.gov
Remote Sensing and Applications Division
National Climatic Data Center
151 Patton Ave
Asheville, NC 28806
828-271-4339 (voice) 828-271-4328 (fax)
Re: Reading in a string file [message #39182 is a reply to message #39176] Tue, 27 April 2004 16:38 Go to previous message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
> IDL> template = ASCII_Template()
> IDL> Read_ASCII(filename, TEMPLATE=template)

Oops. I meant...

IDL> data = Read_ASCII(filename, TEMPLATE=template)
Re: Reading in a string file [message #39183 is a reply to message #39182] Tue, 27 April 2004 16:32 Go to previous message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
Jonathan Greenberg wrote:
> Any hints on how to read a file which is in CSV form where each entry is a
> text string:

[snip]

> For numerical data I usually do a array = READ_ASCII(filename,delimiter=",")
> And then array=array.(0) so I can have it in a normal array format. For
> this data, however, I get an array of NaN

How about creating a template and then using the template along with
READ_ASCII?

IDL> template = ASCII_Template()
IDL> Read_ASCII(filename, TEMPLATE=template)

If you need to reuse the template, just Save it off somewhere and
Restore it in your program. I have a directory full of IDL Save files
each of which is a single template for the specific file types I work with.

-Mike
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Keyboard Events on Windows
Next Topic: Read 3D array into IDL

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

Current Time: Fri Oct 10 14:18:48 PDT 2025

Total time taken to generate the page: 0.80257 seconds