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

Home » Public Forums » archive » question about readf
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: question about readf [message #49623 is a reply to message #49570] Fri, 04 August 2006 07:23 Go to previous messageGo to previous message
savoie is currently offline  savoie
Messages: 68
Registered: September 1996
Member
rlayberry@hotmail.com writes:

> I am trying to get data out of MS-Excel and into IDL as a float array.
>
> I laboriously save each Excel worksheet as a csv.
>
> I then readf the CSV into a float array.
>
> The problem is that there are some missing data values. for example
> ,10.0,,,0.0,10
> so a missing data value is given by two commas next to each other.
> readf assumes no data is there and all my formatting goes to pot. is
> there anyway of getting either excel to write csvs out with dummy
> values (-99.9 for example) or of getting IDL to read in a missing data
> point as a dummy value?

I do this by reading in the entire line first, and then using stregex.


lformat = '(%"%100s")' ; a really long string to read in each line
readf, lun, FORMAT = lformat, line
delimiter = ','
parts = strsplit( line, delimiter, $
count = count, /EXTRACT, /PRESERVE_NULL )
parts = strcompress( parts, /REMOVE_ALL )
nullidx = where( parts eq '', count )
if count gt 0 then begin
parts[ nullidx ] = !values.F_NAN
endif


Just remember the keyword to strsplit: /PRESERVE_NULL.

Hope this helps. If not, I hope someone has a better answer.

Matt

--
Matthew Savoie - Scientific Programmer
National Snow and Ice Data Center
(303) 735-0785 http://nsidc.org
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: VM command line parameters
Next Topic: output in an array

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

Current Time: Sat Oct 11 06:42:16 PDT 2025

Total time taken to generate the page: 0.16126 seconds