MagnusBilling
Operations

Importing CSV files into MagnusBilling: converting UNIX to DOS line endings

Fix CSV imports that report success but load no rows by identifying and converting incompatible line endings.

ENPTES

When MagnusBilling reports a successful CSV import but no rows appear, the file's line endings may not match the format expected by the importer. Windows, Linux and classic macOS historically use different end-of-line characters.

Original featured image for the Unix-to-DOS CSV conversion guide.
Original featured image for the Unix-to-DOS CSV conversion guide.

Line-ending formats

OriginLine endingVisible notation
WindowsCarriage return + line feed\r\n
Linux / UnixLine feed\n
Classic macOSCarriage return\r

Why the import can fail

The legacy importer uses MySQL LOAD DATA LOCAL INFILE, whose LINES TERMINATED BY option is configured for one separator. If the separator in the CSV differs, the importer may interpret the entire file as one line.

Detect the current format

Work on a copy. The file command often identifies CRLF terminators; the other commands make carriage returns visible.

file FILE.csv
cat -v FILE.csv | head
hexdump -C FILE.csv | head

Convert a copy to Windows CRLF

Install dos2unix, preserve the original file and run unix2dos on the copy that will be imported.

apt update
apt install dos2unix -y
cp FILE.csv FILE.original.csv
unix2dos FILE.csv
file FILE.csv

Validate before importing

  • Keep the exact column headers required by the selected MagnusBilling import dialog.
  • Use the expected delimiter and quote fields that contain that delimiter.
  • Save text in UTF-8 unless the installed version documents another encoding.
  • Check that every data row has the same number of columns.
  • Test with a small file before importing a production data set.

Do not confuse this with DID import

This article fixes line endings for any affected CSV import. The DID import guide documents the Number, Setup price and Monthly price columns used by the DID dialog.

Open the DID CSV import guide

Original article

Read the archived original article