Bug 38497 - Denote delimiter in exported report results
Summary: Denote delimiter in exported report results
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Reports (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-20 17:28 UTC by Andrew Fuerste-Henry
Modified: 2024-11-20 19:46 UTC (History)
1 user (show)

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


Attachments
Bug 38497: Denote delimiter in report csv (1.21 KB, patch)
2024-11-20 19:42 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Fuerste-Henry 2024-11-20 17:28:51 UTC
If one's CSV starts with the string "sep=" and then your delimiter character, Excel and Libre office will correctly identify and use that delimiter when opening your file.

To confirm:
 - set CSVDelimiter to #
 - run a report, select * from biblio or something
 - Download as "pound (#) separated text (.csv)"
 - try to open your file with libre office, note that it requires manual definition of delimiter
 - open your CSV in a text editor
 - add a new line at the top of "sep=#", save
 - open with LibreOffice again, note that it uses the correct delimiter
Comment 1 Andrew Fuerste-Henry 2024-11-20 19:42:56 UTC
Created attachment 174860 [details] [review]
Bug 38497: Denote delimiter in report csv

To test:
1- set delimiter to something other than comma
2- run and download report as CSV, try to open in Excel, it doesn't recognize your delimiter
3- apply patch
4- repeat 2, now it does recognize your delimiter
Comment 2 Andrew Fuerste-Henry 2024-11-20 19:46:01 UTC
(In reply to Andrew Fuerste-Henry from comment #1)
> Created attachment 174860 [details] [review] [review]
> Bug 38497: Denote delimiter in report csv
> 
> To test:
> 1- set delimiter to something other than comma
> 2- run and download report as CSV, try to open in Excel, it doesn't
> recognize your delimiter
> 3- apply patch
> 4- repeat 2, now it does recognize your delimiter

Proof of concept, but not setting to NSO. This "sep=" function seems to have pretty spotty implementation (Excel and LibreOffice do it, Numbers does not). And in LibreOffice you end up with a first row that just says "sep=".

Additionally, what I've written here breaks if you're using / as you delimiter. That slash ends up escaping the \ of the "\n" that follows it. I had enough other misgivings that I didn't pursue a fix for this.