Bug 27045 - Tabulation in CSV profile for lost items doesn't export correctly
Summary: Tabulation in CSV profile for lost items doesn't export correctly
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Reports (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-17 21:14 UTC by Katrin Fischer
Modified: 2021-07-14 09:04 UTC (History)
2 users (show)

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


Attachments
Bug 27045: Fix items lost report export if delimiter is tab (1.97 KB, patch)
2020-11-20 14:33 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 27045: Fix other exports (1.83 KB, patch)
2020-11-20 14:33 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Katrin Fischer 2020-11-17 21:14:29 UTC
When choosing tabulation as the delimiter on a CSV profile for the lost item report, it's exported as shown below:

title\tauthor\tstocknumber\tcallnumber
"E Street shuffle :"\"Heylin, Clinton."\\

Tabs works best as default for Excel, so it would be great to see this fixed.

Reads similar like other older closed bugs like bug 17590 and bug 7251.
Comment 1 Katrin Fischer 2020-11-17 21:14:48 UTC
Originally found in 20.05.03, but confirmed in master now.
Comment 2 Jonathan Druart 2020-11-20 14:33:43 UTC
Created attachment 113890 [details] [review]
Bug 27045: Fix items lost report export if delimiter is tab
Comment 3 Jonathan Druart 2020-11-20 14:33:47 UTC
Created attachment 113891 [details] [review]
Bug 27045: Fix other exports
Comment 4 Jonathan Druart 2020-11-20 14:35:15 UTC
Hum, I lost myself. I first thought it was because we were not using Text::CSV::Encoded. But found (after I rewrote itemslost.pl export) that it was because of the way we handle "\t".
I think those 2 patches fixes the problem for all the CSV exports, but have only tried with itemslost so far.
Comment 5 Katrin Fischer 2020-11-20 23:38:26 UTC
Is this ready for testing now?
Comment 6 Jonathan Druart 2020-11-21 07:28:40 UTC
I don't know, see previous comment. Feel free to test it!
Comment 7 Fridolin Somers 2021-05-12 08:45:17 UTC
  my $delimiter = $csv_profile->csv_separator;
  $delimiter = "\t" if $delimiter eq "\\t";

Ah strange :

In system preference stored value is string "tabulation" :
https://git.koha-community.org/Koha-community/Koha/src/commit/99c10bf4484635e9befdc9c09a56c0f7278c7976/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref#L50

We see in other places :
  $delimiter = "\t" if $delimiter eq 'tabulation';
https://git.koha-community.org/Koha-community/Koha/src/commit/65542edbe021d58ca6ef1332a8e3ca760b198391/reports/guided_reports.pl#L903

Looks like use of CSVdelimiter is wrong in many places where preference is fetched in TT.
I create a  new bug report for that.

Maybe we shoud add a method C4::Context->csv_delimiter() ?
And add a method to TT plugin.
Comment 8 Katrin Fischer 2021-07-14 09:04:57 UTC
In this case it's independent of the preference - for CSV profile the delimiter is chosen in configuration. But in general both (pref and CSV profiles) need fixing.