From 15cdc30a91e4b9bad34a823c651ecfc87f833344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= 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 --- .../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 5d859d8c5b..9dd823445e 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.50.1 (Apple Git-155)