/[webpac2]/trunk/lib/WebPAC/Input/CSV.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Input/CSV.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1253 by dpavlin, Tue May 19 14:46:12 2009 UTC revision 1254 by dpavlin, Mon Jul 27 16:24:41 2009 UTC
# Line 7  use WebPAC::Input; Line 7  use WebPAC::Input;
7  use base qw/WebPAC::Common/;  use base qw/WebPAC::Common/;
8    
9  use Text::CSV;  use Text::CSV;
10    use Encode;
11  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
12    
13  =head1 NAME  =head1 NAME
# Line 15  WebPAC::Input::CSV - support for CSV Exp Line 16  WebPAC::Input::CSV - support for CSV Exp
16    
17  =cut  =cut
18    
19  our $VERSION = '0.01';  our $VERSION = '0.02';
20    
21  =head1 FUNCTIONS  =head1 FUNCTIONS
22    
# Line 50  sub new { Line 51  sub new {
51    
52          my $log = $self->_get_logger();          my $log = $self->_get_logger();
53    
54          open( my $fh, '<:encoding(utf-8)', $arg->{path} ) || $log->logconfess("can't open $arg->{path}: $!");          open( my $fh, '<:raw', $arg->{path} ) || $log->logconfess("can't open $arg->{path}: $!");
55    
56          my $csv = Text::CSV->new({ binary => 1 });          my $csv = Text::CSV->new({ binary => 1 });
57    
# Line 66  sub new { Line 67  sub new {
67                  $rec->{'000'} = [ ++$self->{size} ];                  $rec->{'000'} = [ ++$self->{size} ];
68    
69                  my $col = 'A';                  my $col = 'A';
70                  $rec->{ $col++ } = $_ foreach @$line;                  $rec->{ $col++ } = Encode::decode_utf8( $_ ) foreach @$line;
71    
72                  push @{ $self->{_rec} }, $rec;                  push @{ $self->{_rec} }, $rec;
73    
# Line 86  Return record with ID C<$mfn> from datab Line 87  Return record with ID C<$mfn> from datab
87  =cut  =cut
88    
89  sub fetch_rec {  sub fetch_rec {
90          my $self = shift;          my ( $self, $mfn, $filter_coderef ) = @_;
   
         my ( $mfn, $filter_coderef ) = @_;  
91    
92          return $self->{_rec}->[$mfn-1];          return $self->{_rec}->[$mfn-1];
93  }  }

Legend:
Removed from v.1253  
changed lines
  Added in v.1254

  ViewVC Help
Powered by ViewVC 1.1.26