[Bug 41626] New: Add Koha::CSV::Reports for report exports
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41626 Bug ID: 41626 Summary: Add Koha::CSV::Reports for report exports Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: tomascohen@gmail.com QA Contact: testopia@bugs.koha-community.org Depends on: 41619 Blocks: 41621 This bug adds Koha::CSV::Reports to standardize CSV generation for report exports. Files to update: - reports/guided_reports.pl - misc/cronjobs/runreport.pl Benefits: - Consistent CSV formatting across all report exports - Proper quote handling for Excel - Testable code Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41619 [Bug 41619] Add `Koha::CSV` https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41621 [Bug 41621] Use Koha::CSV everywhere [UMBRELLA] -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41626 Bug 41626 depends on bug 41619, which changed state. Bug 41619 Summary: Add `Koha::CSV` https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41619 What |Removed |Added ---------------------------------------------------------------------------- Status|Needs documenting |RESOLVED Resolution|--- |FIXED -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41626 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tomascohen@gmail.com Assignee|koha-bugs@lists.koha-commun |tomascohen@gmail.com |ity.org | Status|NEW |ASSIGNED Depends on| |41620 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41620 [Bug 41620] Make itemsearch.pl use Koha::CSV for CSV generation -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41626 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Trivial patch Status|ASSIGNED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41626 --- Comment #1 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 203487 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=203487&action=edit Bug 41626: Use Koha::CSV for report exports This patch replaces Text::CSV::Encoded with Koha::CSV in both reports/guided_reports.pl and misc/cronjobs/runreport.pl. This is a straightforward swap using the low-level API (combine/string) since report CSV exports have fully dynamic columns determined by the SQL query at runtime, making the columns() subclass pattern unsuitable. Benefits: - CSVDelimiter system preference used consistently - formula => empty enforced (prevents formula injection) - binary => 1 always set (UTF-8 safe) - No more Encode::decode wrapping (Koha::CSV handles encoding) - Removes dependency on Text::CSV::Encoded Note: runreport.pl --quote option is not wired through since Koha::CSV uses the Text::CSV_XS default (double quote). This matches the previous default behavior. A future enhancement could expose quote_char as a Koha::CSV constructor param if needed. Test plan: 1. Apply patches 2. Run a saved report from the staff interface, export as CSV => SUCCESS: CSV generated with correct delimiter and quoting 3. Run from command line: $ ktd --shell k$ perl misc/cronjobs/runreport.pl --format=csv --csv-header 1 => SUCCESS: CSV output with headers 4. Test with custom separator: k$ perl misc/cronjobs/runreport.pl --format=csv --separator=";" 1 => SUCCESS: Semicolon separator used 5. Open in Excel/LibreOffice => SUCCESS: No formula injection, proper quoting 6. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41626 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Add Koha::CSV::Reports for |Use Koha::CSV for report |report exports |exports -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41626 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |david@davidnind.com --- Comment #2 from David Nind <david@davidnind.com> --- I wasn't able to complete steps 3 and 4 - a file wasn't created, and I got an error/warning: 1. Step 3: Don't get any results: perl misc/cronjobs/runreport.pl --format=csv --csv-header 1 Wide character at misc/cronjobs/runreport.pl line 348. 2. Step 4: Don't get any results: perl misc/cronjobs/runreport.pl --format=csv --separator=";" 1 Wide character at misc/cronjobs/runreport.pl line 348. Testing notes (using KTD): 1. Step 2 - used this SQL: SQL: select * from biblio 2. Standard report download - all look OK: - Comma separated text (.csv) - Tab separated text - Open Document Spreadsheet 3. Also tested Open in DataTables > Export > CSV - all looks OK. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41626 --- Comment #5 from David Nind <david@davidnind.com> --- (In reply to Tomás Cohen Arazi (tcohen) from comment #4)
(In reply to David Nind from comment #2)
I wasn't able to complete steps 3 and 4 - a file wasn't created, and I got an error/warning:
1. Step 3: Don't get any results: perl misc/cronjobs/runreport.pl --format=csv --csv-header 1 Wide character at misc/cronjobs/runreport.pl line 348.
Great, I fixed this. It was a stray 'encode' call messing with it.
Thanks Tomás! The command line steps now work, and work as expected. To create a file for opening in Libre Office I added > filename.csv to the end of the commands. However, for step 2, downloading the CSV format (Download > Comma separated text (.csv)) gives unexpected results. There are some characters before first column name, and a blank row between every line of output: "biblionumber","frameworkcode","author","title","medium","subtitle","part_number","part_name","unititle","notes","serial","seriestitle","copyrightdate","timestamp","datecreated","abstract","opac_suppressed" "1","BKS","Heylin, Clinton.","E Street shuffle :",,,,,,,,,,"2020-01-29 12:06:37","2014-05-07",,"0" "2","BKS","Fine, Reuben,","The ideas behind the chess openings /",,,,,,"Includes index.",,,"1990","2020-01-29 12:06:37","2014-05-07",,"0" "3","BKS","Mastronarde, Donald J.","Introduction to Attic Greek /",,,,,,"Includes index.",,,"1993","2020-01-29 12:06:37","2014-05-07",,"0" "4","BKS","Kernighan, Brian W.","The C programming language /",,,,,,"Includes index.",,,"1988","2020-01-29 12:06:37","2014-05-07",,"0" -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41626 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Failed QA -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org