Bugzilla – Attachment 113890 Details for
Bug 27045
Exports using CSV profiles with tab as separator don't work correctly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27045: Fix items lost report export if delimiter is tab
Bug-27045-Fix-items-lost-report-export-if-delimite.patch (text/plain), 1.97 KB, created by
Jonathan Druart
on 2020-11-20 14:33:43 UTC
(
hide
)
Description:
Bug 27045: Fix items lost report export if delimiter is tab
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-11-20 14:33:43 UTC
Size:
1.97 KB
patch
obsolete
>From 58d6f09223aeb8e2b67f53eb2fa077e81b590628 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 20 Nov 2020 15:33:02 +0100 >Subject: [PATCH] Bug 27045: Fix items lost report export if delimiter is tab > >--- > reports/itemslost.pl | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > >diff --git a/reports/itemslost.pl b/reports/itemslost.pl >index 3fcb75d632..e79f7e9cb1 100755 >--- a/reports/itemslost.pl >+++ b/reports/itemslost.pl >@@ -28,7 +28,7 @@ This script displays lost items. > use Modern::Perl; > > use CGI qw ( -utf8 ); >-use Text::CSV_XS; >+use Text::CSV::Encoded; > use C4::Auth; > use C4::Output; > use C4::Biblio; >@@ -64,7 +64,6 @@ if ( $op eq 'export' ) { > my $csv_profile = Koha::CsvProfiles->find( $csv_profile_id ); > die "There is no valid csv profile given" unless $csv_profile; > >- my $csv = Text::CSV_XS->new({'quote_char'=>'"','escape_char'=>'"','sep_char'=>$csv_profile->csv_separator,'binary'=>1}); > my $csv_profile_content = $csv_profile->content; > my ( @headers, @fields ); > while ( $csv_profile_content =~ / >@@ -93,11 +92,16 @@ if ( $op eq 'export' ) { > } > push @rows, \@row; > } >- my $content = join( $csv_profile->csv_separator, @headers ) . "\n"; >+ my $delimiter = $csv_profile->csv_separator; >+ $delimiter = "\t" if $delimiter eq "\\t"; >+ >+ my $csv = Text::CSV::Encoded->new({ encoding_out => 'UTF-8', sep_char => $delimiter}); >+ $csv or die "Text::CSV::Encoded->new({binary => 1}) FAILED: " . Text::CSV::Encoded->error_diag(); >+ $csv->combine(@headers); >+ my $content .= Encode::decode('UTF-8', $csv->string()) . "\n"; > for my $row ( @rows ) { > $csv->combine(@$row); >- my $string = $csv->string; >- $content .= $string . "\n"; >+ $content .= $csv->string . "\n"; > } > print $query->header( > -type => 'text/csv', >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27045
:
113890
|
113891
|
137790
|
137791
|
137792
|
137793
|
137794
|
137933
|
137934
|
137935