Bugzilla – Attachment 192337 Details for
Bug 41617
CSV export from item search results - incorrect spaces after comma separator causes issues
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41617: Remove extra spaces breaking CSV formatting
0dcfbcb.patch (text/plain), 6.60 KB, created by
Martin Renvoize (ashimema)
on 2026-02-02 18:01:06 UTC
(
hide
)
Description:
Bug 41617: Remove extra spaces breaking CSV formatting
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2026-02-02 18:01:06 UTC
Size:
6.60 KB
patch
obsolete
>From 0dcfbcb5750fd6b365902e60a36a65b4064d1f2b Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= <tomascohen@theke.io> >Date: Wed, 14 Jan 2026 15:55:43 -0300 >Subject: [PATCH] Bug 41617: Remove extra spaces breaking CSV formatting >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch removes extra spaces breaking CSV parsing in tools like Excel. > >To test: >1. Perform an item search selecting the CSV option >2. Open the CSV with a TEXT EDITOR of your choice >=> FAIL: Notice the extra spaces after the commas (those used as separators, no the ones within the double quotes) >3. Apply this patch >4. Repeat 1-2 >=> SUCCESS: No extra spaces! >5. Sign off :-D > >Note: On the first attempt you can open the file on Excel if you have it and notice things are not aligned. >Note2: Using double quotes on all fields regardless of the context works for most parsers, but is not correct CSV. Will deal with it on a separate bug. > >Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io> >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> >--- > .../en/includes/catalogue/itemsearch_item.csv.inc | 14 ++------------ > 1 file changed, 2 insertions(+), 12 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc >index 5d859d8c5b8..9dd823445ee 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc >@@ -7,15 +7,5 @@ > [%- SET biblio = item.biblio -%] > [%- SET biblioitem = item.biblioitem -%] > [%- SET delimiter = Koha.CSVDelimiter() -%] >-"[% biblio.title | replace('"', '""') | $raw %] [% IF ( Koha.Preference( 'marcflavour' ) == 'UNIMARC' && biblio.author ) %]by[% END %][% biblio.author | replace('"', '""') | $raw %]" [%- delimiter | $raw -%] >-"[% (biblioitem.publicationyear || biblio.copyrightdate) | replace('"', '""') | $raw %]" [%- delimiter | $raw -%] "[% biblioitem.publishercode | replace('"', '""') | $raw %]" [%- delimiter | $raw -%] >-"[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => item.ccode ) | replace('"', '""') | $raw %]" [%- delimiter | $raw -%] "[% item.barcode | replace('"', '""') | $raw %]" [%- delimiter | $raw -%] >-"[% item.itemnumber | replace('"', '""') | $raw %]" [%- delimiter | $raw -%] "[% item.enumchron | replace('"', '""') | $raw %]" [%- delimiter | $raw -%] "[% item.itemcallnumber | replace('"', '""') | $raw %]" [%- delimiter | $raw -%] >-"[% Branches.GetName(item.homebranch) | replace('"', '""') | $raw %]" [%- delimiter | $raw -%] "[% Branches.GetName(item.holdingbranch) | replace('"', '""') | $raw %]" [%- delimiter | $raw -%] >-"[% AuthorisedValues.GetDescriptionByKohaField(frameworkcode => biblio.frameworkcode, kohafield => 'items.location', authorised_value => item.location) | replace('"', '""') | $raw %]" [%- delimiter | $raw -%] >-"[% ItemTypes.GetDescription(item.itype) | replace('"', '""') | $raw %]" [%- delimiter | $raw -%] "[% item.stocknumber | replace('"', '""') | $raw %]" [%- delimiter | $raw -%] >-"[% AuthorisedValues.GetDescriptionByKohaField(frameworkcode => biblio.frameworkcode, kohafield => 'items.notforloan', authorised_value => item.notforloan) | replace('"', '""') | $raw %]" [%- delimiter | $raw -%] >-"[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.itemlost', authorised_value => item.itemlost ) || "" | replace('"', '""') | $raw %]" [%- delimiter | $raw -%] >-"[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.withdrawn', authorised_value => item.withdrawn ) || "" | replace('"', '""') | $raw %]" [%- delimiter | $raw -%] >-"[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.damaged', authorised_value => item.damaged ) || "" | replace('"', '""') | $raw %]" [%- delimiter | $raw -%] "[% item.dateaccessioned | $KohaDates | $raw %]" >-[%- delimiter | $raw -%] "[% (item.issues || 0) | $raw %]" [%- delimiter | $raw -%] "[% item.datelastborrowed | $KohaDates | $raw %]" [%- delimiter | $raw -%] "[% IF item.checkout %][% item.checkout.date_due | $KohaDates | $raw %][% END %]" >+"[% biblio.title | replace('"', '""') | $raw %] >+[% IF ( Koha.Preference( 'marcflavour' ) == 'UNIMARC' && biblio.author ) %]by[% END %][% biblio.author | replace('"', '""') | $raw %]"[%- delimiter | $raw -%]"[% (biblioitem.publicationyear || biblio.copyrightdate) | replace('"', '""') | $raw %]"[%- delimiter | $raw -%]"[% biblioitem.publishercode | replace('"', '""') | $raw %]"[%- delimiter | $raw -%]"[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => item.ccode ) | replace('"', '""') | $raw %]"[%- delimiter | $raw -%]"[% item.barcode | replace('"', '""') | $raw %]"[%- delimiter | $raw -%]"[% item.itemnumber | replace('"', '""') | $raw %]"[%- delimiter | $raw -%]"[% item.enumchron | replace('"', '""') | $raw %]"[%- delimiter | $raw -%]"[% item.itemcallnumber | replace('"', '""') | $raw %]"[%- delimiter | $raw -%]"[% Branches.GetName(item.homebranch) | replace('"', '""') | $raw %]"[%- delimiter | $raw -%]"[% Branches.GetName(item.holdingbranch) | replace('"', '""') | $raw %]"[%- delimiter | $raw -%]"[% AuthorisedValues.GetDescriptionByKohaField(frameworkcode => biblio.frameworkcode, kohafield => 'items.location', authorised_value => item.location) | replace('"', '""') | $raw %]"[%- delimiter | $raw -%]"[% ItemTypes.GetDescription(item.itype) | replace('"', '""') | $raw %]"[%- delimiter | $raw -%]"[% item.stocknumber | replace('"', '""') | $raw %]"[%- delimiter | $raw -%]"[% AuthorisedValues.GetDescriptionByKohaField(frameworkcode => biblio.frameworkcode, kohafield => 'items.notforloan', authorised_value => item.notforloan) | replace('"', '""') | $raw %]"[%- delimiter | $raw -%]"[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.itemlost', authorised_value => item.itemlost ) || "" | replace('"', '""') | $raw %]"[%- delimiter | $raw -%]"[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.withdrawn', authorised_value => item.withdrawn ) || "" | replace('"', '""') | $raw %]"[%- delimiter | $raw -%]"[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.damaged', authorised_value => item.damaged ) || "" | replace('"', '""') | $raw %]"[%- delimiter | $raw -%]"[% item.dateaccessioned | $KohaDates | $raw %]"[%- delimiter | $raw -%]"[% (item.issues || 0) | $raw %]"[%- delimiter | $raw -%]"[% item.datelastborrowed | $KohaDates | $raw %]"[%- delimiter | $raw -%]"[% IF item.checkout %][% item.checkout.date_due | $KohaDates | $raw %][% END %]" >-- >2.52.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 41617
:
191439
|
191582
|
192337
|
192603