[Rd] Excel -> *.CSV in Unix (Linux) command line?

Dirk Eddelbuettel edd@debian.org
Mon, 20 Aug 2001 20:57:15 -0500

  Martin> 1) newer Perl versions (newer than Redhat 6.2 or Debian potato) 

The Perl version shouldn't matter for as long it can install from the CPAN

  Martin>    Dirk has also done a done a perl script "xls2csv" built on the
  Martin> above, sent to Brian Ripley who forwarded it to me.  Dirk, maybe
  Martin> you'd post the latest version of that here as well, or give us a
  Martin> pointer where that is available?

It just so happened that Brian had asked about that topic when I was playing
with an example from the Spreadsheet::ParseExcel module I was revisiting. I
sent him the hand-edited version (mostly more indentation, renamed variables)
I had plauyed to grok it better. As I'm currently on a different machine, I
can only the (somewhat terse) original dmpEx.pl. There are variants of in the
sample/ directory of Spreadsheet::ParseExcel.

IMHO trying to teach R to read .xls files is opening a huge can of worms with
users who might be a little too agnostic about exactly how they have saved
their data.

Regards, Dirk

use strict;
if(!(defined $ARGV[0])) {
Usage: $0 Excel_File
use Spreadsheet::ParseExcel;
my $oExcel = new Spreadsheet::ParseExcel;
my $oBook = $oExcel->Parse($ARGV[0]);

my($iR, $iC, $oWkS, $oWkC);
print "=========================================\n";
print "FILE  :", $oBook->{File} , "\n";
print "COUNT :", $oBook->{SheetCount} , "\n";
print "AUTHOR:", $oBook->{Author} , "\n";
#for(my $iSheet=0; $iSheet < $oBook->{SheetCount} ; $iSheet++) {
#    $oWkS = $oBook->{Worksheet}[$iSheet];
foreach my $oWkS (@{$oBook->{Worksheet}}) {
    print "--------- SHEET:", $oWkS->{Name}, "\n";
    for(my $iR = $oWkS->{MinRow} ; 
            defined $oWkS->{MaxRow} && $iR <= $oWkS->{MaxRow} ; $iR++) {
        for(my $iC = $oWkS->{MinCol} ;
                        defined $oWkS->{MaxCol} && $iC <= $oWkS->{MaxCol} ; $iC++) {
            $oWkC = $oWkS->{Cells}[$iR][$iC];
            print "( $iR , $iC ) =>", $oWkC->Value, "\n" if($oWkC);
print $oWkC->{_Kind}, "\n";

Our mailserver had a hardware failure while we were gone during the 2nd half 
of July. If I did not respond to a mail you sent then, or if you experienced a
a mail bounce, could you kindly resend it? Sorry for the inconvenience -- Dirk
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch