r29114 - in /branches/upstream/libspreadsheet-read-perl/current: Changes MANIFEST META.yml Makefile.PL Read.pm files/macosx.csv t/22_csv.t

gregoa at users.alioth.debian.org gregoa at users.alioth.debian.org
Thu Jan 1 21:26:11 UTC 2009


Author: gregoa
Date: Thu Jan  1 21:26:08 2009
New Revision: 29114

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=29114
Log:
[svn-upgrade] Integrating new upstream version, libspreadsheet-read-perl (0.30)

Added:
    branches/upstream/libspreadsheet-read-perl/current/files/macosx.csv
    branches/upstream/libspreadsheet-read-perl/current/t/22_csv.t
Modified:
    branches/upstream/libspreadsheet-read-perl/current/Changes
    branches/upstream/libspreadsheet-read-perl/current/MANIFEST
    branches/upstream/libspreadsheet-read-perl/current/META.yml
    branches/upstream/libspreadsheet-read-perl/current/Makefile.PL
    branches/upstream/libspreadsheet-read-perl/current/Read.pm

Modified: branches/upstream/libspreadsheet-read-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libspreadsheet-read-perl/current/Changes?rev=29114&op=diff
==============================================================================
--- branches/upstream/libspreadsheet-read-perl/current/Changes (original)
+++ branches/upstream/libspreadsheet-read-perl/current/Changes Thu Jan  1 21:26:08 2009
@@ -1,6 +1,11 @@
 Revision history for Spreadsheet::Read
 
-0.29	Tue 21 Oct 2008
+0.30	Mon 22 Dec 2008
+
+    - Wrong e-mail in META.yml
+    - CSV files from a Mac, with \r as eol, would not parse
+
+0.29	Sun 19 Oct 2008
 
     - Make Read safer for files that do not match extension,
       like HTML in foo.xls

Modified: branches/upstream/libspreadsheet-read-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libspreadsheet-read-perl/current/MANIFEST?rev=29114&op=diff
==============================================================================
--- branches/upstream/libspreadsheet-read-perl/current/MANIFEST (original)
+++ branches/upstream/libspreadsheet-read-perl/current/MANIFEST Thu Jan  1 21:26:08 2009
@@ -11,6 +11,7 @@
 files/empty.sc
 files/empty.sxc
 files/empty.xls
+files/macosx.csv
 files/macosx.xls
 files/misc.xls
 files/test.csv
@@ -32,6 +33,7 @@
 t/11_call.t
 t/20_csv.t
 t/21_csv.t
+t/22_csv.t
 t/30_xls.t
 t/31_clr.t
 t/33_misc.t

Modified: branches/upstream/libspreadsheet-read-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libspreadsheet-read-perl/current/META.yml?rev=29114&op=diff
==============================================================================
--- branches/upstream/libspreadsheet-read-perl/current/META.yml (original)
+++ branches/upstream/libspreadsheet-read-perl/current/META.yml Thu Jan  1 21:26:08 2009
@@ -1,16 +1,16 @@
 --- #YAML:1.1
 name:                   Read
-version:                0.29
+version:                0.30
 abstract:               Meta-Wrapper for reading spreadsheet data
 license:                perl
 author:                 
-  - H.Merijn Brand <h.merijn at xs4all.nl>
+  - H.Merijn Brand <h.m.brand at xs4all.nl>
 generated_by:           Author
 distribution_type:      module
 provides:
   Spreadsheet::Read:
     file:               Read.pm
-    version:            0.29
+    version:            0.30
 requires:                       
   perl:                 5.006
   Exporter:             0
@@ -31,14 +31,14 @@
     recommends:
       Text::CSV:        1
       Text::CSV_PP:     1.05
-      Text::CSV_XS:     0.56
+      Text::CSV_XS:     0.57
 - opt_excel:
     description:        Provides parsing of Microsoft Excel files
     requires:
       Spreadsheet::ParseExcel: 0.26
       Spreadsheet::ParseExcel::FmtDefault: 0
     recommends:
-      Spreadsheet::ParseExcel: 0.34
+      Spreadsheet::ParseExcel: 0.41
 - opt_oo:
     description:        Provides parsing of OpenOffice spreadsheets
     requires:

Modified: branches/upstream/libspreadsheet-read-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libspreadsheet-read-perl/current/Makefile.PL?rev=29114&op=diff
==============================================================================
--- branches/upstream/libspreadsheet-read-perl/current/Makefile.PL (original)
+++ branches/upstream/libspreadsheet-read-perl/current/Makefile.PL Thu Jan  1 21:26:08 2009
@@ -90,7 +90,8 @@
 	'tgzdist:	checkmeta fixmeta $(DISTVNAME).tar.gz distcheck',
 	'	- at mv -f $(DISTVNAME).tar.gz $(DISTVNAME).tgz',
 	'	- at cpants_lint.pl $(DISTVNAME).tgz',
-	'	- at rm -f Debian_CPANTS.txt';
+	'	- at rm -f Debian_CPANTS.txt',
+	'';
     } # postamble
 
 1;

Modified: branches/upstream/libspreadsheet-read-perl/current/Read.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libspreadsheet-read-perl/current/Read.pm?rev=29114&op=diff
==============================================================================
--- branches/upstream/libspreadsheet-read-perl/current/Read.pm (original)
+++ branches/upstream/libspreadsheet-read-perl/current/Read.pm Thu Jan  1 21:26:08 2009
@@ -21,7 +21,7 @@
 use strict;
 use warnings;
 
-our $VERSION = "0.29";
+our $VERSION = "0.30";
 sub  Version { $VERSION }
 
 use Carp;
@@ -206,6 +206,8 @@
 
 	$debug and print STDERR "Opening CSV $txt\n";
 	open my $in, "<", $txt or return;
+
+	local $/ = $/;
 	my $csv;
 	my @data = (
 	    {	type	=> "csv",
@@ -223,7 +225,16 @@
 		attr	=> [],
 		},
 	    );
+
 	$_ = <$in>;
+	if (eof ($in)) {
+	    # This file is either just one single line, or uses \r as eol
+	    close $in;
+	    open $in, "<", $txt or return;
+	    $/ = "\r";
+	    $_ = <$in>;
+	    }
+
 	my $quo = defined $opt{quote} ? $opt{quote} : '"';
 	my $sep = # If explicitly set, use it
 	   defined $opt{sep} ? $opt{sep} :
@@ -236,15 +247,14 @@
 	       m/\w,[\w,]/		? ","  :
 	       m/\w\t[\w,]/		? "\t" :
 					  ","  ;
-	my ($eol) = m{([\r\n]+)\z};
 	$debug > 1 and print STDERR "CSV sep_char '$sep', quote_char '$quo'\n";
 	$csv = $can{csv}->new ({
 	    sep_char       => ($data[0]{sepchar} = $sep),
 	    quote_char     => ($data[0]{quote}   = $quo),
-	    eol            => $eol,
 	    keep_meta_info => 1,	# Ignored for Text::CSV_XS <= 0.27
 	    binary         => 1,
-	    }) or croak "Cannot create a csv ('$sep', '$quo', '$eol') parser!";
+	    eol            => $/,
+	    }) or croak "Cannot create a csv ('$sep', '$quo') parser!";
 
 	# while ($row = $csv->getline () {
 	# doesn't work, because I have to fetch the first line for auto
@@ -267,6 +277,7 @@
 		$csv = undef;
 		}
 	    } while ($csv && ($row = $csv->getline ($in)));
+	$csv->eof () or $csv->error_diag;
 	close $in;
 
 	for (@{$data[1]{cell}}) {

Added: branches/upstream/libspreadsheet-read-perl/current/files/macosx.csv
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libspreadsheet-read-perl/current/files/macosx.csv?rev=29114&op=file
==============================================================================
--- branches/upstream/libspreadsheet-read-perl/current/files/macosx.csv (added)
+++ branches/upstream/libspreadsheet-read-perl/current/files/macosx.csv Thu Jan  1 21:26:08 2009
@@ -1,0 +1,1 @@
+"'\'\\'\\\'""\""\\""\\\""",,,,,,,,,,,,,,
Exported 12/16/2008 10:30 AM,,,,,,Category,Category name,,,,,Category name 2,,
Username,Last Name,First Name M.,Section/Group,Status,Notes,Assignment,Category name 1,Category name 2,Category name 3,woot!,dqwdqwd,Category name 2 1,Total Score,Class Grade
,,,,,,Grading scale,Points,Points,Points,Points,Points,Points,,
,,,,,,Points possible,11,11,11,11,11,11,,
dcwalker,,,,Dropped,<b>,,1,34,1,,,,109,
jdr99,,,devs,Active,"qwd

qwd


qwd",,12,0,1,,,,39,
jlaney,,,devs,Active,,,,2,23,,,,114,
mcrawfor,,,devs,Active,"line 1
line 2
line 3 XX <b>fwe</b>
and


so

on

yea!",,,,,,,,,
,,,,,,,,,,,,,,
,,,,,,Mean,6.5,12.0,8.33,#DIV/0!,#DIV/0!,#DIV/0!,87.33,
,,,,,,Median,6.5,2.0,1.0,#NUM!,#NUM!,#NUM!,109.0,
,,,,,,Mode,#N/A,#N/A,1.0,#N/A,#N/A,#N/A,#N/A,
,,,,,,Min,1.0,0.0,1.0,0.0,0.0,0.0,39.0,
,,,,,,Max,12.0,34.0,23.0,0.0,0.0,0.0,114.0,
,,,,,,Std. Dev.,7.78,19.08,12.7,#DIV/0!,#DIV/0!,#DIV/0!,41.93,

Added: branches/upstream/libspreadsheet-read-perl/current/t/22_csv.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libspreadsheet-read-perl/current/t/22_csv.t?rev=29114&op=file
==============================================================================
--- branches/upstream/libspreadsheet-read-perl/current/t/22_csv.t (added)
+++ branches/upstream/libspreadsheet-read-perl/current/t/22_csv.t Thu Jan  1 21:26:08 2009
@@ -1,0 +1,42 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use Spreadsheet::Read;
+if (Spreadsheet::Read::parses ("csv")) {
+    plan "no_plan";
+    }
+else {
+    plan skip_all => "No CSV parser found";
+    }
+
+my $csv;
+ok ($csv = ReadData ("files/macosx.csv"),	"Read/Parse csv file");
+
+#use DP; DDumper $csv;
+
+is ($csv->[1]{maxrow},		16,		"Last row");
+is ($csv->[1]{maxcol},		15,		"Last column");
+is ($csv->[1]{cell}[$csv->[1]{maxcol}][$csv->[1]{maxrow}],
+				"",		"Last field");
+
+__END__
+ok (1, "Defined fields");
+foreach my $cell (qw( A1 A2 A3 A4 B1 B2 B4 C3 C4 D1 D3 )) {
+    my ($c, $r) = cell2cr ($cell);
+    is ($csv->[1]{cell}[$c][$r],	$cell,	"Unformatted cell $cell");
+    is ($csv->[1]{$cell},		$cell,	"Formatted   cell $cell");
+    }
+
+ok (1, "Undefined fields");
+foreach my $cell (qw( B3 C1 C2 D2 D4 )) {
+    my ($c, $r) = cell2cr ($cell);
+    is ($csv->[1]{cell}[$c][$r],	"",   	"Unformatted cell $cell");
+    is ($csv->[1]{$cell},		"",   	"Formatted   cell $cell");
+    }
+is ($csv->[0]{sepchar},	",",			"{sepchar}");
+is ($csv->[0]{quote},	'"',			"{quote}");
+is ($csv->[1]{C3},      "C3",			"cell C3");




More information about the Pkg-perl-cvs-commits mailing list