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

Home » Public Forums » archive » Re: readcol with empty fields
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: readcol with empty fields [message #49901] Wed, 30 August 2006 10:59 Go to previous message
news.verizon.net is currently offline  news.verizon.net
Messages: 47
Registered: August 2003
Member
burkina wrote:

> Instead, I need all the lines to be read and, when the field is empty,
> a value of 0 (or, better, something like NULL, something that should be
> ignored) should be put in the vector if it's a number, or simply the
> null string if it's a string field.
>

1. For strings, READCOL should already work as you wish -- an empty
field will be read as an empty string.

2. For numeric fields, try downloading a new version of strnumber.pro
from http://idlastro.gsfc.nasa.gov/ftp/pro/misc/strnumber.pro
In ancient history (1993) , there was a kluge added to strnumber.pro
such that an empty string was not considered a valid number. (At
that time, doing otherwise could corrupt the ~V3.6 IDL session.) I
have now removed this kluge so READCOL will read empty strings into
zero values.

3. For floating point numbers, you probably don't want a zero value
but rather a NaN value. In this case, I'd read the column,say f6, as
a string array, and identify the empty strings before converting to
float.

f6 = strtrim(f6,2)
bad = where(strlen(f6) EQ 0, Nbad)
if Nbad GT 0 then f6[bad] = 'NaN'
f6 = float(f6)

I suppose it would be useful to have a /NAN keyword to READCOL do this
automatically.

--Wayne
[Message index]
 
Read Message
Read Message
Previous Topic: Re: drawing a ROI on a zoomed image
Next Topic: Postscript device coordinates

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

Current Time: Fri Oct 10 14:27:11 PDT 2025

Total time taken to generate the page: 0.39991 seconds