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

(-)a/C4/Acquisition.pm (-1 / +9 lines)
Lines 279-285 sub GetBasketAsCSV { Link Here
279
279
280
        my $delimiter = $csv_profile->csv_separator;
280
        my $delimiter = $csv_profile->csv_separator;
281
        $delimiter = "\t" if $delimiter eq "\\t";
281
        $delimiter = "\t" if $delimiter eq "\\t";
282
        my $csv = Text::CSV_XS->new({'quote_char'=>'"','escape_char'=>'"','sep_char'=>$delimiter,'binary'=>1});
282
        my $csv = Text::CSV_XS->new(
283
            {
284
                quote_char  => '"',
285
                escape_char => '"',
286
                sep_char    => $delimiter,
287
                binary      => 1,
288
                formula     => "empty",
289
            }
290
        );
283
        my $csv_profile_content = $csv_profile->content;
291
        my $csv_profile_content = $csv_profile->content;
284
        my ( @headers, @fields );
292
        my ( @headers, @fields );
285
        while ( $csv_profile_content =~ /
293
        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 113-119 sub _get_label_item { Link Here
113
113
114
sub _get_text_fields {
114
sub _get_text_fields {
115
    my $format_string = shift;
115
    my $format_string = shift;
116
    my $csv = Text::CSV_XS->new({allow_whitespace => 1});
116
    my $csv = Text::CSV_XS->new( { allow_whitespace => 1, formula => "empty" } );
117
    my $status = $csv->parse($format_string);
117
    my $status = $csv->parse($format_string);
118
    my @sorted_fields = map {{ 'code' => $_, desc => $_ }} 
118
    my @sorted_fields = map {{ 'code' => $_, desc => $_ }} 
119
                        map { $_ && $_ eq 'callnumber' ? 'itemcallnumber' : $_ } # see bug 5653
119
                        map { $_ && $_ eq 'callnumber' ? 'itemcallnumber' : $_ } # see bug 5653
(-)a/C4/Record.pm (-1 / +1 lines)
Lines 400-406 sub marc2csv { Link Here
400
    my ($biblios, $id, $itemnumbers) = @_;
400
    my ($biblios, $id, $itemnumbers) = @_;
401
    $itemnumbers ||= [];
401
    $itemnumbers ||= [];
402
    my $output;
402
    my $output;
403
    my $csv = Text::CSV::Encoded->new();
403
    my $csv = Text::CSV::Encoded->new( { formula => "empty" } );
404
404
405
    # Getting yaml file
405
    # Getting yaml file
406
    my $configfile = "../tools/csv-profiles/$id.yaml";
406
    my $configfile = "../tools/csv-profiles/$id.yaml";
(-)a/Koha/Patrons/Import.pm (-1 / +1 lines)
Lines 614-620 sub generate_patron_attributes { Link Here
614
    push (@$feedback, { feedback => 1, name => 'attribute string', value => $string });
614
    push (@$feedback, { feedback => 1, name => 'attribute string', value => $string });
615
    return [] unless $string; # Unit tests want the feedback, is it really needed?
615
    return [] unless $string; # Unit tests want the feedback, is it really needed?
616
616
617
    my $csv = Text::CSV->new({binary => 1});  # binary needed for non-ASCII Unicode
617
    my $csv = Text::CSV->new( { binary => 1, formula => "empty" } );    # binary needed for non-ASCII Unicode
618
    my $ok   = $csv->parse($string);  # parse field again to get subfields!
618
    my $ok   = $csv->parse($string);  # parse field again to get subfields!
619
    my @list = $csv->fields();
619
    my @list = $csv->fields();
620
    my @patron_attributes =
620
    my @patron_attributes =
(-)a/admin/aqplan.pl (-1 / +3 lines)
Lines 429-436 sub _print_to_csv { Link Here
429
    binmode STDOUT, ':encoding(UTF-8)';
429
    binmode STDOUT, ':encoding(UTF-8)';
430
430
431
    my $csv = Text::CSV_XS->new(
431
    my $csv = Text::CSV_XS->new(
432
        {   sep_char     => $del,
432
        {
433
            sep_char     => $del,
433
            always_quote => 'TRUE',
434
            always_quote => 'TRUE',
435
            formula      => "empty",
434
        }
436
        }
435
    );
437
    );
436
    print $input->header(
438
    print $input->header(
(-)a/circ/overdue.pl (-1 / +1 lines)
Lines 401-407 sub build_csv { Link Here
401
    my @keys =
401
    my @keys =
402
      qw ( duedate title author borrowertitle firstname surname phone barcode email address address2 zipcode city country
402
      qw ( duedate title author borrowertitle firstname surname phone barcode email address address2 zipcode city country
403
      branchcode itemcallnumber biblionumber borrowernumber itemnum issuedate replacementprice itemnotes_nonpublic streetnumber streettype);
403
      branchcode itemcallnumber biblionumber borrowernumber itemnum issuedate replacementprice itemnotes_nonpublic streetnumber streettype);
404
    my $csv = Text::CSV_XS->new();
404
    my $csv = Text::CSV_XS->new( { formula => "empty" } );
405
    $csv->combine(@keys);
405
    $csv->combine(@keys);
406
    push @lines, $csv->string();
406
    push @lines, $csv->string();
407
407
(-)a/labels/label-create-csv.pl (-1 / +1 lines)
Lines 66-72 else { Link Here
66
    $items = $batch->get_attr('items');
66
    $items = $batch->get_attr('items');
67
}
67
}
68
68
69
my $csv = Text::CSV_XS->new();
69
my $csv = Text::CSV_XS->new( { formula => "empty" } );
70
70
71
foreach my $item (@$items) {
71
foreach my $item (@$items) {
72
    my $label = C4::Labels::Label->new(
72
    my $label = C4::Labels::Label->new(
(-)a/misc/cronjobs/overdue_notices.pl (-1 / +1 lines)
Lines 412-418 our $csv; # the Text::CSV_XS object Link Here
412
our $csv_fh;    # the filehandle to the CSV file.
412
our $csv_fh;    # the filehandle to the CSV file.
413
if ( defined $csvfilename ) {
413
if ( defined $csvfilename ) {
414
    my $sep_char = C4::Context->csv_delimiter;
414
    my $sep_char = C4::Context->csv_delimiter;
415
    $csv = Text::CSV_XS->new( { binary => 1 , sep_char => $sep_char } );
415
    $csv = Text::CSV_XS->new( { binary => 1, sep_char => $sep_char, formula => "empty" } );
416
    if ( $csvfilename eq '' ) {
416
    if ( $csvfilename eq '' ) {
417
        $csv_fh = *STDOUT;
417
        $csv_fh = *STDOUT;
418
    } else {
418
    } else {
(-)a/misc/cronjobs/runreport.pl (-6 / +9 lines)
Lines 306-317 foreach my $report_id (@ARGV) { Link Here
306
        }
306
        }
307
        $message = $cgi->table(join "", @rows);
307
        $message = $cgi->table(join "", @rows);
308
    } elsif ($format eq 'csv') {
308
    } elsif ($format eq 'csv') {
309
        my $csv = Text::CSV::Encoded->new({
309
        my $csv = Text::CSV::Encoded->new(
310
            encoding_out => 'utf8',
310
            {
311
            binary      => 1,
311
                encoding_out => 'utf8',
312
            quote_char  => $quote,
312
                binary       => 1,
313
            sep_char    => $separator,
313
                quote_char   => $quote,
314
            });
314
                sep_char     => $separator,
315
                formula      => 'empty',
316
            }
317
        );
315
318
316
        if ( $csv_header ) {
319
        if ( $csv_header ) {
317
            my @fields = map { decode( 'utf8', $_ ) } @{ $sth->{NAME} };
320
            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 / +7 lines)
Lines 924-930 elsif ($phase eq 'Export'){ Link Here
924
            if ( $format eq 'csv' ) {
924
            if ( $format eq 'csv' ) {
925
                my $delimiter = C4::Context->csv_delimiter;
925
                my $delimiter = C4::Context->csv_delimiter;
926
                $type = 'application/csv';
926
                $type = 'application/csv';
927
                my $csv = Text::CSV::Encoded->new({ encoding_out => 'UTF-8', sep_char => $delimiter});
927
                my $csv = Text::CSV::Encoded->new(
928
                    {
929
                        encoding_out => 'UTF-8',
930
                        sep_char     => $delimiter,
931
                        formula      => 'empty',
932
                    }
933
                );
928
                $csv or die "Text::CSV::Encoded->new({binary => 1}) FAILED: " . Text::CSV::Encoded->error_diag();
934
                $csv or die "Text::CSV::Encoded->new({binary => 1}) FAILED: " . Text::CSV::Encoded->error_diag();
929
                if ($csv->combine(header_cell_values($sth))) {
935
                if ($csv->combine(header_cell_values($sth))) {
930
                    $content .= Encode::decode('UTF-8', $csv->string()) . "\n";
936
                    $content .= 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 '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 38-49 die "There is no valid csv profile given" unless $csv_profile; Link Here
38
my $delimiter = $csv_profile->csv_separator;
38
my $delimiter = $csv_profile->csv_separator;
39
$delimiter = "\t" if $delimiter eq "\\t";
39
$delimiter = "\t" if $delimiter eq "\\t";
40
40
41
my $csv = Text::CSV_XS->new({
41
my $csv = Text::CSV_XS->new(
42
    'quote_char'  => '"',
42
    {
43
    'escape_char' => '"',
43
        quote_char  => '"',
44
    'sep_char'    => $delimiter,
44
        escape_char => '"',
45
    'binary'      => 1
45
        sep_char    => $delimiter,
46
});
46
        binary      => 1,
47
        formula     => 'empty',
48
    }
49
);
47
50
48
my $content = $csv_profile->content;
51
my $content = $csv_profile->content;
49
my ( @headers, @fields );
52
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 77-83 $template->param( categories => \@patron_categories ); Link Here
77
$template->param( borrower_fields => Koha::Database::Columns->columns->{borrowers} );
77
$template->param( borrower_fields => Koha::Database::Columns->columns->{borrowers} );
78
78
79
if ( $input->param('sample') ) {
79
if ( $input->param('sample') ) {
80
    our $csv = Text::CSV->new( { binary => 1 } );    # binary needed for non-ASCII Unicode
80
    our $csv = Text::CSV->new( { binary => 1, formula => 'empty' } );    # binary needed for non-ASCII Unicode
81
    print $input->header(
81
    print $input->header(
82
        -type       => 'application/vnd.sun.xml.calc',    # 'application/vnd.ms-excel' ?
82
        -type       => 'application/vnd.sun.xml.calc',    # 'application/vnd.ms-excel' ?
83
        -attachment => 'patron_import.csv',
83
        -attachment => 'patron_import.csv',
(-)a/tools/inventory.pl (-3 / +3 lines)
Lines 374-382 $template->param( Link Here
374
374
375
# Export to csv
375
# Export to csv
376
if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){
376
if (defined $input->param('CSVexport') && $input->param('CSVexport') eq 'on'){
377
    eval {use Text::CSV ();};
377
    eval { use Text::CSV (); };
378
    my $csv = Text::CSV->new or
378
    my $csv = Text::CSV->new( { formula => 'empty' } )
379
            die Text::CSV->error_diag ();
379
        or die Text::CSV->error_diag();
380
    binmode STDOUT, ":encoding(UTF-8)";
380
    binmode STDOUT, ":encoding(UTF-8)";
381
    print $input->header(
381
    print $input->header(
382
        -type       => 'text/csv',
382
        -type       => 'text/csv',
(-)a/tools/viewlog.pl (-2 / +1 lines)
Lines 232-238 if ($do_it) { Link Here
232
        my $content = q{};
232
        my $content = q{};
233
        if (@data) {
233
        if (@data) {
234
            my $delimiter = C4::Context->csv_delimiter;
234
            my $delimiter = C4::Context->csv_delimiter;
235
            my $csv = Text::CSV::Encoded->new( { encoding_out => 'utf8', sep_char => $delimiter } );
235
            my $csv = Text::CSV::Encoded->new( { encoding_out => 'utf8', sep_char => $delimiter, formula => 'empty' } );
236
            $csv or die "Text::CSV::Encoded->new FAILED: " . Text::CSV::Encoded->error_diag();
236
            $csv or die "Text::CSV::Encoded->new FAILED: " . Text::CSV::Encoded->error_diag();
237
237
238
            # First line with heading
238
            # First line with heading
239
- 

Return to bug 33339