From: Tara L Andrews Date: Sat, 1 Sep 2012 00:29:44 +0000 (+0200) Subject: handle Excel 2007+ parsing as well X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bb23d86106e1ccee868c7903f6496da77d4dfd11;p=scpubgit%2Fstemmaweb.git handle Excel 2007+ parsing as well --- diff --git a/lib/stemmaweb/Controller/Root.pm b/lib/stemmaweb/Controller/Root.pm index 7bdbf1e..639d7c1 100644 --- a/lib/stemmaweb/Controller/Root.pm +++ b/lib/stemmaweb/Controller/Root.pm @@ -240,17 +240,18 @@ sub newtradition :Local :Args(0) { } last if $tradition; } - } elsif( $ext eq 'txt' || $ext eq 'csv' || $ext eq 'xls' ) { - # If it's Excel we need to pass xls => [true value]; + } elsif( $ext =~ /^(txt|csv|xls(x)?)$/ ) { + # If it's Excel we need to pass excel => $ext; # otherwise we need to pass sep_char => [record separator]. - # Good thing record separators are true values. - my $extrafield = $ext eq 'xls' ? 'xls' : 'sep_char'; - my $extraarg = $ext eq 'txt' ? "\t" : ','; + if( $ext =~ /xls/ ) { + $newopts{'excel'} = $ext; + } else { + $newopts{'sep_char'} = $ext eq 'txt' ? "\t" : ','; + } try { $tradition = Text::Tradition->new( %newopts, 'input' => 'Tabular', - $extrafield => $extraarg ); } catch ( Text::Tradition::Error $e ) { $errmsg = $e->message;