Re: Reading in a string file [message #39176] |
Wed, 28 April 2004 07:24 |
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 #39183 is a reply to message #39182] |
Tue, 27 April 2004 16:32  |
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
|
|
|