Bugzilla – Attachment 156133 Details for
Bug 33050
Allow to specify quote char in runreport.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33050: Allow to specify quote char in runreport.pl
Bug-33050-Allow-to-specify-quote-char-in-runreport.patch (text/plain), 2.64 KB, created by
David Nind
on 2023-09-24 06:20:20 UTC
(
hide
)
Description:
Bug 33050: Allow to specify quote char in runreport.pl
Filename:
MIME Type:
Creator:
David Nind
Created:
2023-09-24 06:20:20 UTC
Size:
2.64 KB
patch
obsolete
>From 53d18a2287db0918be57de44b0fdc1c8dede9da7 Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Wed, 22 Feb 2023 20:40:14 -1000 >Subject: [PATCH] Bug 33050: Allow to specify quote char in runreport.pl > >Add to script misc/cronjobs/runreport.pl quote char arg (only for CSV). >See perl doc https://metacpan.org/pod/Text::CSV#new > >This patch also adds missing '--separator' in POD. > >Test plan : >1 - Write a SQL report >2 - perl misc/cronjobs/runreport.pl --format csv 1 (or correct report number) >3 - Note you get double quotes >4 - Apply patch >5 - Repeat #2 - no change >6 - perl misc/cronjobs/runreport.pl --format csv --quote "'" 1 >7 - Now it is single quote delimited >8 - perl misc/cronjobs/runreport.pl --format tsv --separator "'" 1 >9 - Error is reported, you cannot set quote unless csv >10 - Try empty string as quote > >Signed-off-by: David Nind <david@davidnind.com> >--- > misc/cronjobs/runreport.pl | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > >diff --git a/misc/cronjobs/runreport.pl b/misc/cronjobs/runreport.pl >index debcf5a024..771fc3f305 100755 >--- a/misc/cronjobs/runreport.pl >+++ b/misc/cronjobs/runreport.pl >@@ -63,6 +63,8 @@ runreport.pl [ -h | -m ] [ -v ] reportID [ reportID ... ] > --subject=s subject for the e-mail > --param=s parameters for the report > --store-results store the result of the report >+ --separator separator character for csv >+ --quote quote character for csv > --csv-header add column names as first line of csv output > > >@@ -93,6 +95,11 @@ Current options are text, html, csv, and tsv. At the moment, text and tsv both p > > Separator character, only for csv format. Default to comma. > >+=item B<--quote> >+ >+Quote character, only for csv format. Default to double quote. >+Empty string is allowed. >+ > =item B<--email> > > Whether to use e-mail (implied by --to or --from). >@@ -188,6 +195,7 @@ my $quote = '"'; > my $store_results = 0; > my $csv_header = 0; > my $csv_separator = ""; >+my $csv_quote = ""; > > my $username = undef; > my $password = undef; >@@ -201,6 +209,7 @@ GetOptions( > 'verbose' => \$verbose, > 'format=s' => \$format, > 'separator=s' => \$csv_separator, >+ 'quote=s' => \$csv_quote, > 'to=s' => \$to, > 'from=s' => \$from, > 'subject=s' => \$subject, >@@ -233,6 +242,14 @@ if ($csv_separator) { > } > } > >+if ($csv_quote) { >+ if ( $format eq 'csv' ) { >+ $quote = "$csv_quote"; >+ } else { >+ print STDERR "Cannot specify quote if not using CSV format\n"; >+ } >+} >+ > if ($format eq 'tsv' || $format eq 'text') { > $format = 'csv'; > $separator = "\t"; >-- >2.30.2
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 33050
:
147187
|
147188
|
152499
|
156133
|
158207
|
158208