Bug 41622

Summary: Make patron export use Koha::CSV
Product: Koha Reporter: Tomás Cohen Arazi (tcohen) <tomascohen>
Component: Architecture, internals, and plumbingAssignee: Tomás Cohen Arazi (tcohen) <tomascohen>
Status: Needs Signoff --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: dcook, tomascohen
Version: Main   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 41619    
Bug Blocks: 41621    
Attachments: Bug 41622: Make patron export use Koha::CSV

Description Tomás Cohen Arazi (tcohen) 2026-01-14 20:19:36 UTC

    
Comment 1 Tomás Cohen Arazi (tcohen) 2026-01-14 20:24:01 UTC
Created attachment 191469 [details] [review]
Bug 41622: Make patron export use Koha::CSV

This patch introduces Koha::CSV::Patrons and updates misc/export_borrowers.pl
to use it, providing consistent CSV generation with proper quoting and
delimiter handling.

Changes:
- Add Koha::CSV::Patrons with dynamic field support
- Update misc/export_borrowers.pl to use Koha::CSV::Patrons
- Simplify export logic by removing manual CSV handling
- Maintain all existing functionality (field selection, custom separator)

The new class supports configurable field lists, making it flexible for
different patron export scenarios while ensuring consistent CSV formatting.

Test plan:
1. Apply patch
2. Run:
   $ ktd --shell
  k$ prove t/db_dependent/Koha/CSV/Patrons.t
=> SUCCESS: Tests pass!
3. Test patron export:
  k$ misc/export_borrowers.pl --show-header > patrons.csv
=> SUCCESS: CSV generated with all fields
4. Test with specific fields:
  k$ misc/export_borrowers.pl -H -f cardnumber -f surname -f firstname > patrons.csv
=> SUCCESS: Only specified fields exported
5. Test with custom separator:
  k$ misc/export_borrowers.pl -H -s=";" > patrons.csv
=> SUCCESS: Semicolon separator used
6. Open CSV in Excel
=> SUCCESS: Fields display correctly without quote issues
7. Sign off :-D