Bug 8376 - Command line utility for exporting borrowers
Summary: Command line utility for exporting borrowers
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: 3.10
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Julian Maurice
QA Contact:
URL:
Keywords:
Depends on:
Blocks: 9045
  Show dependency treegraph
 
Reported: 2012-07-06 10:30 UTC by Julian Maurice
Modified: 2013-12-05 20:01 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 8376: New script to export borrowers misc/export_borrowers.pl (3.65 KB, patch)
2012-07-06 10:37 UTC, Julian Maurice
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 8376: New script to export borrowers misc/export_borrowers.pl (3.72 KB, patch)
2012-07-06 12:39 UTC, Gaetan Boisson
Details | Diff | Splinter Review
Bug 8376: New script to export borrowers misc/export_borrowers.pl (4.10 KB, patch)
2012-07-20 08:41 UTC, Robin Sheat
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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.