View | Details | Raw Unified | Return to bug 33339
Collapse All | Expand All

(-)a/C4/Acquisition.pm (-1 / +9 lines)
Lines 277-283 sub GetBasketAsCSV { Link Here
277
277
278
        my $delimiter = $csv_profile->csv_separator;
278
        my $delimiter = $csv_profile->csv_separator;
279
        $delimiter = "\t" if $delimiter eq "\\t";
279
        $delimiter = "\t" if $delimiter eq "\\t";
280
        my $csv = Text::CSV_XS->new({'quote_char'=>'"','escape_char'=>'"','sep_char'=>$delimiter,'binary'=>1});
280
        my $csv = Text::CSV_XS->new(
281
            {
282
                quote_char  => '"',
283
                escape_char => '"',
284
                sep_char    => $delimiter,
285
                binary      => 1,
286
                formula     => "empty",
287
            }
288
        );
281
        my $csv_profile_content = $csv_profile->content;
289
        my $csv_profile_content = $csv_profile->content;
282
        my ( @headers, @fields );
290
        my ( @headers, @fields );
283
        while ( $csv_profile_content =~ /
291
        while ( $csv_profile_content =~ /
(-)a/C4/ImportExportFramework.pm (-1 / +1 lines)
Lines 965-971 sub _import_table_csv Link Here
965
    shift @fieldsPK;
965
    shift @fieldsPK;
966
    my $ok = 0;
966
    my $ok = 0;
967
    my $pos = 0;
967
    my $pos = 0;
968
    my $csv = Text::CSV_XS->new ({ binary => 1 });
968
    my $csv = Text::CSV_XS->new( { binary => 1, formula => "empty" } );
969
    while ( my $row = $csv->getline($dom) ) {
969
    while ( my $row = $csv->getline($dom) ) {
970
        my @fields = @$row;
970
        my @fields = @$row;
971
        @arrData = @fields;
971
        @arrData = @fields;
(-)a/C4/Labels/Label.pm (-1 / +1 lines)
Lines 115-121 sub _get_label_item { Link Here
115
115
116
sub _get_text_fields {
116
sub _get_text_fields {
117
    my $format_string = shift;
117
    my $format_string = shift;
118
    my $csv = Text::CSV_XS->new({allow_whitespace => 1});
118
    my $csv = Text::CSV_XS->new( { allow_whitespace => 1, formula => "empty" } );
119
    my $status = $csv->parse($format_string);
119
    my $status = $csv->parse($format_string);
120
    my @sorted_fields = map {{ 'code' => $_, desc => $_ }} 
120
    my @sorted_fields = map {{ 'code' => $_, desc => $_ }} 
121
                        map { $_ && $_ eq 'callnumber' ? 'itemcallnumber' : $_ } # see bug 5653
121
                        map { $_ && $_ eq 'callnumber' ? 'itemcallnumber' : $_ } # see bug 5653
(-)a/C4/Record.pm (-1 / +1 lines)
Lines 401-407 sub marc2csv { Link Here
401
    my ($biblios, $id, $itemnumbers) = @_;
401
    my ($biblios, $id, $itemnumbers) = @_;
402
    $itemnumbers ||= [];
402
    $itemnumbers ||= [];
403
    my $output;
403
    my $output;
404
    my $csv = Text::CSV::Encoded->new();
404
    my $csv = Text::CSV::Encoded->new( { formula => "empty" } );
405
405
406
    # Getting yaml file
406
    # Getting yaml file
407
    my $configfile = "../tools/csv-profiles/$id.yaml";
407
    my $configfile = "../tools/csv-profiles/$id.yaml";
(-)a/Koha/Patrons/Import.pm (-1 / +1 lines)
Lines 627-633 sub generate_patron_attributes { Link Here
627
    push (@$feedback, { feedback => 1, name => 'attribute string', value => $string });
627
    push (@$feedback, { feedback => 1, name => 'attribute string', value => $string });
628
    return [] unless $string; # Unit tests want the feedback, is it really needed?
628
    return [] unless $string; # Unit tests want the feedback, is it really needed?
629
629
630
    my $csv = Text::CSV->new({binary => 1});  # binary needed for non-ASCII Unicode
630
    my $csv = Text::CSV->new( { binary => 1, formula => "empty" } );    # binary needed for non-ASCII Unicode
631
    my $ok   = $csv->parse($string);  # parse field again to get subfields!
631
    my $ok   = $csv->parse($string);  # parse field again to get subfields!
632
    my @list = $csv->fields();
632
    my @list = $csv->fields();
633
    my @patron_attributes =
633
    my @patron_attributes =
(-)a/admin/aqplan.pl (-1 / +3 lines)
Lines 418-425 sub _print_to_csv { Link Here
418
    binmode STDOUT, ':encoding(UTF-8)';
418
    binmode STDOUT, ':encoding(UTF-8)';
419
419
420
    my $csv = Text::CSV_XS->new(
420
    my $csv = Text::CSV_XS->new(
421
        {   sep_char     => $del,
421
        {
422
            sep_char     => $del,
422
            always_quote => 'TRUE',
423
            always_quote => 'TRUE',
424
            formula      => "empty",
423
        }
425
        }
424
    );
426
    );
425
    print $input->header(
427
    print $input->header(
(-)a/circ/overdue.pl (-1 / +1 lines)
Lines 434-440 sub build_csv { Link Here
434
    my @keys =
434
    my @keys =
435
        qw ( duedate title author borrowertitle firstname surname phone barcode email address address2 zipcode city country
435
        qw ( duedate title author borrowertitle firstname surname phone barcode email address address2 zipcode city country
436
        branchcode datelastissued itemcallnumber biblionumber borrowernumber itemnum issuedate replacementprice itemnotes_nonpublic streetnumber streettype);
436
        branchcode datelastissued itemcallnumber biblionumber borrowernumber itemnum issuedate replacementprice itemnotes_nonpublic streetnumber streettype);
437
    my $csv = Text::CSV_XS->new();
437
    my $csv = Text::CSV_XS->new( { formula => "empty" } );
438
    $csv->combine(@keys);
438
    $csv->combine(@keys);
439
    push @lines, $csv->string();
439
    push @lines, $csv->string();
440
440
(-)a/labels/label-create-csv.pl (-1 / +1 lines)
Lines 73-79 else { Link Here
73
    $items = $batch->get_attr('items');
73
    $items = $batch->get_attr('items');
74
}
74
}
75
75
76
my $csv = Text::CSV_XS->new();
76
my $csv = Text::CSV_XS->new( { formula => "empty" } );
77
77
78
foreach my $item (@$items) {
78
foreach my $item (@$items) {
79
    my $label = C4::Labels::Label->new(
79
    my $label = C4::Labels::Label->new(
(-)a/misc/cronjobs/overdue_notices.pl (-1 / +1 lines)
Lines 415-421 our $csv; # the Text::CSV_XS object Link Here
415
our $csv_fh;    # the filehandle to the CSV file.
415
our $csv_fh;    # the filehandle to the CSV file.
416
if ( defined $csvfilename ) {
416
if ( defined $csvfilename ) {
417
    my $sep_char = C4::Context->csv_delimiter;
417
    my $sep_char = C4::Context->csv_delimiter;
418
    $csv = Text::CSV_XS->new( { binary => 1 , sep_char => $sep_char } );
418
    $csv = Text::CSV_XS->new( { binary => 1, sep_char => $sep_char, formula => "empty" } );
419
    if ( $csvfilename eq '' ) {
419
    if ( $csvfilename eq '' ) {
420
        $csv_fh = *STDOUT;
420
        $csv_fh = *STDOUT;
421
    } else {
421
    } else {
(-)a/misc/cronjobs/runreport.pl (-6 / +9 lines)
Lines 329-340 foreach my $report_id (@ARGV) { Link Here
329
        }
329
        }
330
        $message = $cgi->table(join "", @rows);
330
        $message = $cgi->table(join "", @rows);
331
    } elsif ($format eq 'csv') {
331
    } elsif ($format eq 'csv') {
332
        my $csv = Text::CSV::Encoded->new({
332
        my $csv = Text::CSV::Encoded->new(
333
            encoding_out => 'utf8',
333
            {
334
            binary      => 1,
334
                encoding_out => 'utf8',
335
            quote_char  => $quote,
335
                binary       => 1,
336
            sep_char    => $separator,
336
                quote_char   => $quote,
337
            });
337
                sep_char     => $separator,
338
                formula      => 'empty',
339
            }
340
        );
338
341
339
        if ( $csv_header ) {
342
        if ( $csv_header ) {
340
            my @fields = map { decode( 'utf8', $_ ) } @{ $sth->{NAME} };
343
            my @fields = map { decode( 'utf8', $_ ) } @{ $sth->{NAME} };
(-)a/misc/export_borrowers.pl (-1 / +1 lines)
Lines 94-100 unless ( $separator ) { Link Here
94
    $separator = C4::Context->csv_delimiter;
94
    $separator = C4::Context->csv_delimiter;
95
}
95
}
96
96
97
my $csv = Text::CSV->new( { sep_char => $separator, binary => 1 } );
97
my $csv = Text::CSV->new( { sep_char => $separator, binary => 1, formula => 'empty' } );
98
98
99
# If the user did not specify any field to export, we assume they want them all
99
# If the user did not specify any field to export, we assume they want them all
100
# We retrieve the first borrower informations to get field names
100
# We retrieve the first borrower informations to get field names
(-)a/misc/migration_tools/import_lexile.pl (-1 / +1 lines)
Lines 96-102 if ( $help || !$file || !$confirm ) { Link Here
96
96
97
my $schema = Koha::Database->new()->schema();
97
my $schema = Koha::Database->new()->schema();
98
98
99
my $csv = Text::CSV->new( { binary => 1, sep_char => "\t" } )
99
my $csv = Text::CSV->new( { binary => 1, sep_char => "\t", formula => 'empty' } )
100
  or die "Cannot use CSV: " . Text::CSV->error_diag();
100
  or die "Cannot use CSV: " . Text::CSV->error_diag();
101
101
102
open my $fh, "<:encoding(utf8)", $file or die "test.csv: $!";
102
open my $fh, "<:encoding(utf8)", $file or die "test.csv: $!";
(-)a/reports/cash_register_stats.pl (-1 lines)
Lines 23-29 use C4::Reports qw( GetDelimiterChoices ); Link Here
23
use C4::Output qw( output_html_with_http_headers );
23
use C4::Output qw( output_html_with_http_headers );
24
use DateTime;
24
use DateTime;
25
use Koha::DateUtils qw( dt_from_string );
25
use Koha::DateUtils qw( dt_from_string );
26
use Text::CSV::Encoded;
27
use List::Util qw( any );
26
use List::Util qw( any );
28
27
29
use Koha::Account::CreditTypes;
28
use Koha::Account::CreditTypes;
(-)a/reports/guided_reports.pl (-1 / +1 lines)
Lines 646-652 elsif ($op eq 'export'){ Link Here
646
            if ( $format eq 'csv' ) {
646
            if ( $format eq 'csv' ) {
647
                my $delimiter = C4::Context->csv_delimiter;
647
                my $delimiter = C4::Context->csv_delimiter;
648
                $type = 'application/csv';
648
                $type = 'application/csv';
649
                my $csv = Text::CSV::Encoded->new({ encoding_out => 'UTF-8', sep_char => $delimiter});
649
                my $csv = Text::CSV::Encoded->new({ encoding_out => 'UTF-8', sep_char => $delimiter, formula => 'empty' });
650
                $csv or die "Text::CSV::Encoded->new({binary => 1}) FAILED: " . Text::CSV::Encoded->error_diag();
650
                $csv or die "Text::CSV::Encoded->new({binary => 1}) FAILED: " . Text::CSV::Encoded->error_diag();
651
                if ( $csv->combine( header_cell_values($sth) ) ) {
651
                if ( $csv->combine( header_cell_values($sth) ) ) {
652
                    $content .= $scrubber->scrub( Encode::decode( 'UTF-8', $csv->string() ) ) . "\n";
652
                    $content .= $scrubber->scrub( Encode::decode( 'UTF-8', $csv->string() ) ) . "\n";
(-)a/reports/itemslost.pl (-2 / +1 lines)
Lines 28-34 This script displays lost items. Link Here
28
use Modern::Perl;
28
use Modern::Perl;
29
29
30
use CGI qw ( -utf8 );
30
use CGI qw ( -utf8 );
31
use Text::CSV_XS;
32
use C4::Auth qw( get_template_and_user );
31
use C4::Auth qw( get_template_and_user );
33
use C4::Output qw( output_html_with_http_headers );
32
use C4::Output qw( output_html_with_http_headers );
34
use Text::CSV::Encoded;
33
use Text::CSV::Encoded;
Lines 91-97 if ( $op eq 'cud-export' ) { Link Here
91
        my $delimiter = $csv_profile->csv_separator;
90
        my $delimiter = $csv_profile->csv_separator;
92
        $delimiter = "\t" if $delimiter eq "\\t";
91
        $delimiter = "\t" if $delimiter eq "\\t";
93
92
94
        my $csv = Text::CSV::Encoded->new({ encoding_out => 'UTF-8', sep_char => $delimiter});
93
        my $csv = Text::CSV::Encoded->new( { encoding_out => 'UTF-8', sep_char => $delimiter, formula => 'empty' } );
95
        $csv or die "Text::CSV::Encoded->new({binary => 1}) FAILED: " . Text::CSV::Encoded->error_diag();
94
        $csv or die "Text::CSV::Encoded->new({binary => 1}) FAILED: " . Text::CSV::Encoded->error_diag();
96
        $csv->combine(@headers);
95
        $csv->combine(@headers);
97
        my $content .= Encode::decode('UTF-8', $csv->string()) . "\n";
96
        my $content .= Encode::decode('UTF-8', $csv->string()) . "\n";
(-)a/serials/lateissues-export.pl (-6 / +9 lines)
Lines 46-57 die "There is no valid csv profile given" unless $csv_profile; Link Here
46
my $delimiter = $csv_profile->csv_separator;
46
my $delimiter = $csv_profile->csv_separator;
47
$delimiter = "\t" if $delimiter eq "\\t";
47
$delimiter = "\t" if $delimiter eq "\\t";
48
48
49
my $csv = Text::CSV_XS->new({
49
my $csv = Text::CSV_XS->new(
50
    'quote_char'  => '"',
50
    {
51
    'escape_char' => '"',
51
        quote_char  => '"',
52
    'sep_char'    => $delimiter,
52
        escape_char => '"',
53
    'binary'      => 1
53
        sep_char    => $delimiter,
54
});
54
        binary      => 1,
55
        formula     => 'empty',
56
    }
57
);
55
58
56
my $content = $csv_profile->content;
59
my $content = $csv_profile->content;
57
my ( @headers, @fields );
60
my ( @headers, @fields );
(-)a/t/db_dependent/Record/marcrecord2csv.t (-1 / +1 lines)
Lines 30-36 my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, $frameworkcode ); Link Here
30
30
31
my $csv_content = q(Title=245$a|Author=245$c|Subject=650$a);
31
my $csv_content = q(Title=245$a|Author=245$c|Subject=650$a);
32
my $csv_profile_id_1 = insert_csv_profile({ csv_content => $csv_content });
32
my $csv_profile_id_1 = insert_csv_profile({ csv_content => $csv_content });
33
my $csv = Text::CSV::Encoded->new();
33
my $csv = Text::CSV::Encoded->new( { formula => 'empty' } );
34
34
35
# Test bad biblionumber case
35
# Test bad biblionumber case
36
my $csv_output = C4::Record::marcrecord2csv( -1, $csv_profile_id_1, 1, $csv );
36
my $csv_output = C4::Record::marcrecord2csv( -1, $csv_profile_id_1, 1, $csv );
(-)a/tools/import_borrowers.pl (-1 / +1 lines)
Lines 78-84 $template->param( categories => \@patron_categories ); Link Here
78
$template->param( borrower_fields => Koha::Database::Columns->columns->{borrowers} );
78
$template->param( borrower_fields => Koha::Database::Columns->columns->{borrowers} );
79
79
80
if ( $input->param('sample') ) {
80
if ( $input->param('sample') ) {
81
    our $csv = Text::CSV->new( { binary => 1 } );    # binary needed for non-ASCII Unicode
81
    our $csv = Text::CSV->new( { binary => 1, formula => 'empty' } );    # binary needed for non-ASCII Unicode
82
    print $input->header(
82
    print $input->header(
83
        -type       => 'application/vnd.sun.xml.calc',    # 'application/vnd.ms-excel' ?
83
        -type       => 'application/vnd.sun.xml.calc',    # 'application/vnd.ms-excel' ?
84
        -attachment => 'patron_import.csv',
84
        -attachment => 'patron_import.csv',
(-)a/tools/inventory.pl (-3 / +3 lines)
Lines 372-380 $template->param( Link Here
372
372
373
# Export to csv
373
# Export to csv
374
if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){
374
if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){
375
    eval {use Text::CSV ();};
375
    eval { use Text::CSV (); };
376
    my $csv = Text::CSV->new or
376
    my $csv = Text::CSV->new( { formula => 'empty' } )
377
            die Text::CSV->error_diag ();
377
        or die Text::CSV->error_diag();
378
    binmode STDOUT, ":encoding(UTF-8)";
378
    binmode STDOUT, ":encoding(UTF-8)";
379
    print $input->header(
379
    print $input->header(
380
        -type       => 'text/csv',
380
        -type       => 'text/csv',
(-)a/tools/viewlog.pl (-2 / +1 lines)
Lines 234-240 if ($do_it) { Link Here
234
        my $content = q{};
234
        my $content = q{};
235
        if (@data) {
235
        if (@data) {
236
            my $delimiter = C4::Context->csv_delimiter;
236
            my $delimiter = C4::Context->csv_delimiter;
237
            my $csv = Text::CSV::Encoded->new( { encoding_out => 'utf8', sep_char => $delimiter } );
237
            my $csv = Text::CSV::Encoded->new( { encoding_out => 'utf8', sep_char => $delimiter, formula => 'empty' } );
238
            $csv or die "Text::CSV::Encoded->new FAILED: " . Text::CSV::Encoded->error_diag();
238
            $csv or die "Text::CSV::Encoded->new FAILED: " . Text::CSV::Encoded->error_diag();
239
239
240
            # First line with heading
240
            # First line with heading
241
- 

Return to bug 33339