Your files stay in this browser

Advertising and analytics are currently off. We remember only a dismissed-notice preference for this tab. Cloudflare may use technical security cookies. Cookies & storage details · File privacy

Practical guide

Remove empty CSV rows and trim whitespace deliberately

Separate empty records from missing cells and meaningful quoted line breaks.

An empty record is different from an empty cell

A CSV can contain a record with no useful fields, a record with one missing value, or a quoted field containing a line break. Those need different treatment. Removing every blank-looking line from the raw text can cut a valid field in half. Parse the file first, then decide whether the whole record is empty.

id,note
00127,"First line

Third line"
,
00904,
00008,"  Café mug  "

This original teaching example has four data records. The first note contains two line breaks, including a visually blank line. The , record has two empty fields and can be removed with the empty-record rule. The 00904, record contains an identifier and must stay. The final note has two spaces on each edge; trimming is a separate choice.

Preview the rules separately

  1. Load the source into CSV clean with all rules off. Select the correct delimiter and header setting.
  2. Enable Remove records whose fields are all empty, then preview. Only the , record disappears in this example. The multiline note and the missing single note remain.
  3. Enable trim only if edge whitespace has no meaning in your dataset. Preview again and compare the trimmed field examples.
  4. Review source record numbers, total removed records and the chosen export scope. Download a new CSV while retaining your source.

Inspect empty records and spaces →

Spaces belong to fields until you deliberately remove them

RFC 4180 describes spaces as part of a CSV field. CSV quoting encloses values; it is not a request to trim them. TableMender leaves all spaces unchanged unless you enable its trim rule. That rule uses JavaScript's String.trim(), which removes whitespace and line terminators at the beginning and end, including tabs. It preserves whitespace inside the value.

Trimming can therefore remove a deliberate trailing newline from a note, turn a space-only value into an empty field, or change a padded code. It never converts 00127 into 127, and never collapses internal spaces in Café mug. A field containing an internal line break retains that line break unless it occurs at an edge.

The cleaning order explains the counts

TableMender applies trimming first, empty-record removal second and deduplication last. With trim off, a field holding three spaces is not empty. With trim on, a row of space-only fields becomes eligible for removal. The trimmed-cell count includes cells in subsequently removed rows, so it measures operations rather than only changes in surviving rows. The header is exempt from every cleaning rule.

An empty physical line may parse as a single empty field in a wider file. With empty-record removal explicitly enabled, it can be removed. Other uneven records remain visible and block export. The tool does not add missing delimiters to make a damaged record appear valid.

Use checks that reflect your destination

Compare at least one missing cell, one multiline note, one identifier and the last result record. Search and pagination inspect the result; they do not define the export scope. Choose All result records for the entire cleaned file, or Only records matching the filter for all matches across pages. Formula protection may add an apostrophe to formula-like fields in the exported CSV and is disclosed separately from cleaning. If the result is unsuitable, Restore original preview resets the cleaning rules without overwriting the source.

Sources:

Examples are original teaching data. Tool-specific behavior describes this version of TableMender; software interfaces can vary by version.

← All guides