From 079df9a4d46aefd1be1f54cb396b7ca4e5ff468e Mon Sep 17 00:00:00 2001 From: Adrien Saurat Date: Thu, 4 Oct 2012 12:00:07 +0200 Subject: [PATCH] Bug 8874: adds a separator parameter for patron export Adds a --separator parameter to export_borrowers.pl Default separator stays the comma. --- misc/export_borrowers.pl | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/misc/export_borrowers.pl b/misc/export_borrowers.pl index c4b3e40..2540995 100755 --- a/misc/export_borrowers.pl +++ b/misc/export_borrowers.pl @@ -44,6 +44,11 @@ $0 -h keys returned by the GetMemberDetails function. If no field is specified, then all fields will be exported. + -s, --separator=CHAR This character will be used to separate fields. + Some characters like | or ; will need to be escaped + or surrounded by quotes in the parameter setting, + like -s=\\| or -s='|'; + If no separator is specified, a comma will be used. -H, --show-header Print field names on first row -h, --help Show this help @@ -52,11 +57,13 @@ USAGE # Getting parameters my @fields; +my $separator; my $show_header; my $help; GetOptions( 'field|f=s' => \@fields, + 'separator|s=s' => \$separator, 'show-header|H' => \$show_header, 'help|h' => \$help ) or print_usage, exit 1; @@ -72,7 +79,7 @@ my $query = "SELECT borrowernumber FROM borrowers ORDER BY borrowernumber"; my $sth = $dbh->prepare($query); $sth->execute; -my $csv = Text::CSV->new( { binary => 1 } ); +my $csv = Text::CSV->new( { sep_char => $separator, binary => 1 } ); # If the user did not specify any field to export, we assume he wants them all # We retrieve the first borrower informations to get field names -- 1.7.4.1