From: Tara L Andrews Date: Fri, 31 Aug 2012 23:46:53 +0000 (+0200) Subject: enable XLS parsing in web controller X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4b2a244a96cc96deff974a8df620619ca68de6d6;p=scpubgit%2Fstemmatology.git enable XLS parsing in web controller --- diff --git a/stemmaweb/lib/stemmaweb/Controller/Root.pm b/stemmaweb/lib/stemmaweb/Controller/Root.pm index 3ff836f..7bdbf1e 100644 --- a/stemmaweb/lib/stemmaweb/Controller/Root.pm +++ b/stemmaweb/lib/stemmaweb/Controller/Root.pm @@ -240,22 +240,26 @@ sub newtradition :Local :Args(0) { } last if $tradition; } - } elsif( $ext eq 'txt' || $ext eq 'csv' ) { - my $sep_char = $ext eq 'txt' ? "\t" : ','; + } elsif( $ext eq 'txt' || $ext eq 'csv' || $ext eq 'xls' ) { + # If it's Excel we need to pass xls => [true value]; + # 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" : ','; try { $tradition = Text::Tradition->new( %newopts, 'input' => 'Tabular', - 'sep_char' => $sep_char + $extrafield => $extraarg ); } catch ( Text::Tradition::Error $e ) { $errmsg = $e->message; } catch { $errmsg = "Unexpected parsing error"; } - } elsif( $ext =~ /^xls(x)?$/ ) { + } elsif( $ext eq 'xlsx' ) { $c->stash->{'result'} = - { 'error' => "Excel parsing not supported yet" }; + { 'error' => "Excel XML parsing not supported yet" }; $c->response->status( 500 ); } else { # Error unless we have a recognized filename extension