help-octave
[Top][All Lists]
Advanced

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

Re: Reading CSV data and preserving empty cells?


From: Jordi Gutiérrez Hermoso
Subject: Re: Reading CSV data and preserving empty cells?
Date: Tue, 30 Mar 2010 10:38:16 -0600

On 29 March 2010 19:06, forkandwait <address@hidden> wrote:
>>
>> 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.

How about Perl?

     perl -pi -e 'chomp; $_ = join(",", map {$_ eq "" ? "NaN" : $_}
split(/,/,$_,-1))."\n";' YOUR_CSV_FILE.csv

Seems to work for me. Backup your original CSV in case I made a mistake, though.

And Perl is fast, so I wouldn't worry about lots and lots of columns...



reply via email to

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