Bug 8376

Summary: Command line utility for exporting borrowers
Product: Koha Reporter: Julian Maurice <julian.maurice>
Component: Command-line UtilitiesAssignee: Julian Maurice <julian.maurice>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P5 - low CC: gaetan.boisson, jonathan.druart, paul.poulain, robin
Version: 3.10   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 9045    
Attachments: Bug 8376: New script to export borrowers misc/export_borrowers.pl
[SIGNED-OFF] Bug 8376: New script to export borrowers misc/export_borrowers.pl
Bug 8376: New script to export borrowers misc/export_borrowers.pl

Description Julian Maurice 2012-07-06 10:30:21 UTC

    
Comment 1 Julian Maurice 2012-07-06 10:37:43 UTC Comment hidden (obsolete)
Comment 2 Gaetan Boisson 2012-07-06 12:39:21 UTC Comment hidden (obsolete)
Comment 3 Gaetan Boisson 2012-07-06 12:42:27 UTC
Tested various exciting possiblities :
- Exporting borrowers with or without headers
- Exporting data with commas inside the fields
- Exporting a specified set of fields
- Specifying a field that doesn't exist (you'll just get an empty column in the csv)

It all works really well. Signing off!
Comment 4 Robin Sheat 2012-07-20 08:40:29 UTC
Found an issue: if a record contains an invalid character (e.g. a newline), a blank line is output. It's possible to see that something went wrong by noting that $csv->string is empty/undefined.

It's also possible to make it deal with these by putting {binary=>1} in the contructor for Text::CSV.

I've added some code to improve handling of funny data, and announcing that something is wrong when it can't be handled.
Comment 5 Robin Sheat 2012-07-20 08:41:50 UTC
Created attachment 11033 [details] [review]
Bug 8376: New script to export borrowers misc/export_borrowers.pl

This script prints to standard output what is returned by
GetMemberDetails in CSV format.
Exported fields can be specified with option -f. If no -f option is
specified, all fields are exported.

Signed-off-by: Gaetan Boisson <gaetan.boisson@biblibre.com>
Signed-off-by: Robin Sheat <robin@catalyst.net.nz>

Amended with some code to better handle bad data.
Comment 6 Jonathan Druart 2012-07-20 09:15:34 UTC
QA Comments:

Works well, code clean.

Marking as Passed QA.

It would be great to specify a list of borrowernumber (or cardnumber) to export (with a file given in parameter for example).
Comment 7 Paul Poulain 2012-07-24 15:56:52 UTC
QA comment:

passes perlcritic

(In reply to comment #6)
> It would be great to specify a list of borrowernumber (or cardnumber) to
> export (with a file given in parameter for example).

Other possible enhancements :
 * provide the separator in a parameter
 * add a WHERE clause to filter, for example, on a given zipcode, categorycode, email,...


Another comment: we don't have a coding guideline for that, but I think we should:
the help should be in POD, like what we have, for example, in:
misc/maintenance/touch_all_biblios.pl

use Pod::Usage;
sub usage {
    pod2usage( -verbose => 2 );
    exit;
}

i'll send a mail to koha-devel to propose this rule.

Patch pushed, though
Comment 8 Julian Maurice 2012-08-03 10:42:59 UTC
Ok in master.