[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reading CSV data and preserving empty cells?
From: |
forkandwait |
Subject: |
Re: Reading CSV data and preserving empty cells? |
Date: |
Tue, 30 Mar 2010 01:06:45 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
>
> Didn't you already ask this?
>
> http://n4.nabble.com/Alternative-missing-values-in-readcsv-
td1632243.html#a1632243
>
> Or were you unsatisfied with the response given there? If so, why?
Yes, I was unsatisfied, because of the problems with textread I spoke about in
the latest email (I don't want to write a format string for 250 columns, over
and over again as I download multiple data sets). Also, the sed solution
doesn't work, nor can I think of a unix text based solution that will scale to
lots and lots of columns.
cell2csv works brilliantly, except for putting a blank in where I want NaN,
partly because of the weird fact that cell array strings that parse as numbers
are useable in arithmetic expressions like so:
x = {1}
x{1} + 1
ans = 2
I thought cellidx would work, looking for empty strings with '' and reassigning
with NaN, but for some reason it craps out on my data. The problem was a type
error which fired when I tried to use cellidx on this data, mixing numerics
with ''. I don't have a reproducible example of this surprising error, so it
will have to wait.
I was sort of hoping that someone had figured out something in the meantime ...
I don't know how to modify the csv2cell in the octave-forge miscellaneous
package, since my local copy is an "oct" file, would need to be recompiled,
etc. If there is a quick guide to fiddling with oct files, I would be
interested in a link, but I am not sure I have enough time to deal with it in
the next few months.
I will post my solution as I come up with one.