Bugzilla – Attachment 69460 Details for
Bug 19716
Add option to send header line for CSV output with runreport.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19716 - Add option to send header line for CSV output
Bug-19716---Add-option-to-send-header-line-for-CSV.patch (text/plain), 2.03 KB, created by
David Bourgault
on 2017-12-01 21:09:37 UTC
(
hide
)
Description:
Bug 19716 - Add option to send header line for CSV output
Filename:
MIME Type:
Creator:
David Bourgault
Created:
2017-12-01 21:09:37 UTC
Size:
2.03 KB
patch
obsolete
>From 2a829c65906310f518c78a3b2b060b96df7ca81b Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 29 Nov 2017 15:20:19 -0500 >Subject: [PATCH] Bug 19716 - Add option to send header line for CSV output > >Currently, if outputting a CSV file using runreport.pl, you need to look at the report used to know what each column means. It would be nice if we could include column headers. > >Test Plan: >1) Apply this patch >2) Try using runreport.pl with --format csv --csv-header > >Signed-off-by: David Bourgault <david.bourgault@inlibro.com> >--- > misc/cronjobs/runreport.pl | 11 +++++++++++ > 1 file changed, 11 insertions(+) > >diff --git a/misc/cronjobs/runreport.pl b/misc/cronjobs/runreport.pl >index 1648f4d..cb10125 100755 >--- a/misc/cronjobs/runreport.pl >+++ b/misc/cronjobs/runreport.pl >@@ -66,6 +66,7 @@ runreport.pl [ -h | -m ] [ -v ] reportID [ reportID ... ] > --from=s e-mail address to send report from > --subject=s subject for the e-mail > --store-results store the result of the report >+ --csv-header add column names as first line of csv output > > > Arguments: >@@ -175,6 +176,7 @@ my $subject = ""; > my $separator = ','; > my $quote = '"'; > my $store_results = 0; >+my $csv_header = 0; > > my $username = undef; > my $password = undef; >@@ -194,6 +196,7 @@ GetOptions( > 'password:s' => \$password, > 'method:s' => \$method, > 'store-results' => \$store_results, >+ 'csv-header' => \$csv_header, > > ) or pod2usage(2); > pod2usage( -verbose => 2 ) if ($man); >@@ -273,6 +276,14 @@ foreach my $report_id (@ARGV) { > quote_char => $quote, > sep_char => $separator, > }); >+ >+ if ( $csv_header ) { >+ my $fields = $sth->{NAME}; >+ $csv->combine( @$fields ); >+ $message .= $csv->string() . "\n"; >+ push @rows_to_store, [@$fields] if $store_results; >+ } >+ > while (my $line = $sth->fetchrow_arrayref) { > $csv->combine(@$line); > $message .= $csv->string() . "\n"; >-- >2.7.4
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 19716
:
69424
|
69460
|
72560