help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Alternative missing values in readcsv?


From: John W. Eaton
Subject: Re: Alternative missing values in readcsv?
Date: Tue, 16 Feb 2010 10:40:52 -0500

On 16-Feb-2010, Jordi Guti rrez Hermoso wrote:

| On 16 February 2010 09:15, forkandwait <address@hidden> wrote:
| >> How about
| >>
| >>      A(find(isnan(A))) = 0
| >>
| >> after you've read into A from your CSV file?
| >
| > Often nan signifies something completely different from zero, and you would
| > lose this information.  For example, a column might be how much you earned,
| > with nan signifying not in the labor force, but zero signifying you earned,
| > well, zero.  Which is different.
| 
| I'm sorry. I read your problem backwards. You want to change zeros to
| nans, not nans to zeros. I presume you're using the dlmread function?
| In that case, it doesn't seem like it comes with what you want. But
| it's very easy to fix your file so that dlmread reads nans instead of
| zeros:
| 
|      s/,,/,nan,/g your_file

This fails for something like ",,,":

  $ echo ',,,' | sed 's/,,/,nan,/g'
  ,nan,,

It would be simpler if cvsread or dlmread allowed one to specify the
value to use for missing values.

Matlab's textscan allows this type of thing with parameter/value
option pairs (I think the option is EmptyValue), but cvsread and
dlmread do not, and cvsread is even documented to return 0 for missing
values.

Octave does not yet have a compatible textead function.  Is there one
in Octave Forge that could be adapted?  If so, does it handle
parameter/value option pairs?

What about also adding parameter/value options to Octave's cvsread and
dlmread?

If you want to discuss the details of implementing any of these
options, please use the maintainers list.

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]