From dc7fb83485e5babde8dea2e4da037163d3ce2a00 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 20 Mar 2023 20:08:56 +0000 Subject: [PATCH] Bug 33285: Allow specifying the delimeter for runreport.pl To test: 1 - Write a report in koha 2 - perl misc/cronjobs/runreport.pl --format csv 1 (or correct report number) 3 - Note you get commas 4 - Apply patch 5 - Repeat #2 - no change 6 - perl misc/cronjobs/runreport.pl --format csv --separator "|" 1 7 - Now it is pipe delimited 8 - perl misc/cronjobs/runreport.pl --format tsv --separator "|" 1 9 - Error is reported, you cannot set separator unless csv 10 - Try other separators Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Fridolin Somers Signed-off-by: Tomas Cohen Arazi (cherry picked from commit bad0d52245ebf7fe73131e3721a99f7ec9a965ce) Signed-off-by: Jacob O'Mara (cherry picked from commit 94077abab8c9c0f5fb5ad08966acd3ff8e44bd31) Signed-off-by: Lucas Gass --- misc/cronjobs/runreport.pl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/misc/cronjobs/runreport.pl b/misc/cronjobs/runreport.pl index 103cc0d29c..418158f19b 100755 --- a/misc/cronjobs/runreport.pl +++ b/misc/cronjobs/runreport.pl @@ -183,6 +183,7 @@ my $separator = ','; my $quote = '"'; my $store_results = 0; my $csv_header = 0; +my $csv_separator = ""; my $username = undef; my $password = undef; @@ -193,6 +194,7 @@ GetOptions( 'man' => \$man, 'verbose' => \$verbose, 'format=s' => \$format, + 'separator=s' => \$csv_separator, 'to=s' => \$to, 'from=s' => \$from, 'subject=s' => \$subject, @@ -217,6 +219,14 @@ unless ($format) { $format = 'text'; } +if( $csv_separator ){ + if( $format eq 'csv' ) { + $separator = "$csv_separator"; + } else { + print STDERR "Cannot specify separator if not using CSV format\n"; + } +} + if ($format eq 'tsv' || $format eq 'text') { $format = 'csv'; $separator = "\t"; -- 2.39.5