Tablora

Tablora · Library

Preserve a line break inside a table cell

A quoted CSV cell can hold a line break, so one record spans two physical lines. Count parsed rows, not lines, and check how each export treats it.

One record, two lines of text

Addresses, delivery notes and comments often contain line breaks. CSV allows that when the field is quoted: everything between the opening and closing quote belongs to one cell, line breaks included. In a text editor the record looks like two lines; in a correct import it is one row with one multi-line cell.

That is why counting lines is not a reliable way to count records. A file can have more physical lines than records without any reading error on either side.

This matters for any check that counts lines, such as the line count an editor or a command-line tool reports. Use the Rows figure from the inspector instead, which counts parsed records.

Example: First line and Second line

The page example has a header id,note and a record whose note is "First line" and "Second line" on two lines inside one pair of quotes. With comma as the Delimiter the inspector reports 2 rows and 2 columns, not 3 rows. Row 2, column 2 contains First line, a line break, and Second line, all in one cell.

Inspecting multi-line notes

How each export handles the line break

When the receiving program disagrees

Some import dialogs have an option for line breaks in quoted fields, and some tools do not support them at all. If the receiving program splits the note, check its import settings first; the file itself is already correct when the inspector shows 2 rows here.

Original synthetic example

Input
id,note 1,"First line Second line"
Delimiter
,
Expected records
2
Columns in the first record
2
Cell to inspect
Row 2, column 2: First line Second line

Tools

Sources