CSV Header / data delimiter interpretation

Example:

Abruf-Nr;Rahmenvertrag-Nr;Los-Nr;Abrufberechtigtes Mitglied;Träger;Stelle;Lieferanschrift des Warenempfängers;Lieferanten- bzw Hersteller-Art-Nr;Artikelkurzbezeichnung;Produktkategorie;Bestell-Nr des Bestellers;Bestellmenge;Einzelpreis in EURO ohne MwSt, gemäß Rechnung;Abrechnungsmonat;Bestell-Datum
4497;PV38-2021-04;Los 5;Wolfsburg;;Stadt WolfsburgPorschestraße 4938440 Wolfsburg;Stadt WolfsburgAlbert-Schweitzer-GymnasiumHalberstädter Straße 3038444 Wolfsburg;4937270;Lenovo ThinkVision E22-40 Monitor;TFT 21,5 Zoll;1000-3610223637 - Albert-Schweitzer;14;112,53;04.09.2026;13.05.2026

Directus uses a comma as a separator here, which leads to an error in data mapping.
It appears that the value “TFT 21,5 Zoll” causes Directus to use the comma character as a delimiter. If I change the value to “TFT 21.5 Zoll”, the semicolon is used as the delimiter.

How can I ensure that the semicolon is used as the delimiter?

1 Answer

1

This comes from how the Directus CSV import reads the file. The import service passes it to Papa Parse with header: true and no delimiter option (api/src/services/import/import.ts), so Papa Parse guesses the delimiter from the first 10 lines by checking which candidate gives the most consistent number of columns per line.

In your file the header Einzelpreis in EURO ohne MwSt, gemäß Rechnung contains a comma and the data has decimal commas, so the comma also produces 2 to 3 “columns” per line. On a small file the empty line after the final newline is counted as well, and that one-column line hurts the ; candidate more than the , one.

I reproduced it with papaparse 5.5.3 (the version Directus pins) using your header and row:

  • 1 to 8 data rows ending with a newline: detected as , (2 columns)
  • the same rows without the final newline: ; (15 columns)
  • 9 or more data rows, with or without the final newline: ; (15 columns)
  • your 1 row with 21.5 instead of 21,5: ;, which is why that change seemed to fix it

So for a quick fix on a small file, delete the empty line at the end (no line break after the last row), or import a file with at least 9 rows. The import has no delimiter setting, so if you want it robust regardless of size, give it a real comma separated file: in LibreOffice Calc open it with ; as separator, then Save As > Text CSV with field delimiter , and string delimiter ". Values containing a comma (TFT 21,5 Zoll, the price header) are then quoted, and Directus reads all 15 columns. Importing JSON instead of CSV avoids the guessing completely.

Separate thing to check: 112,53 arrives as the text “112,53”, not a number. If that column is a decimal or float field, convert the prices to 112.53 first.

(Disclosure: I’m connected to thirds.ai.)

@gordian Thank you very much for this detailed explanation! That explains some of Directus's unexpected reactions... I can't control the length or content of the CSV file, so I have to define rules for what the content should look like as much as possible. I receive the files from an external source and need to somehow detect or verify whether the content adheres to the rules... Your explanation has helped me (and surely others as well) a lot!

–