tsvkit.org
TSV Toolkit
Sample data Say hi →

Remove Empty Rows from a TSV

fully blank · any blank cell · specific column blank

Blank rows come from spreadsheet exports that included the formatting rows below the data, from concatenated files, and from someone deleting a row's contents rather than the row. They break row counts, produce phantom records on import, and turn up as an all-null row in a database. This removes them, with three definitions of "empty" so you can be precise about what to drop.

remove
Drop a .tsv file here, or
ready

How to use

  1. Paste or drop the file.
  2. Start with every cell is empty — it's the safe option and removes the genuine blank lines.
  3. Use these columns are empty when a record without an ID or an email is worthless to you. Name one or more columns; a row is dropped if any of them is blank.
  4. Check the removed count in the status line before downloading. A big number means the definition was broader than you intended.

The three modes, and when each is wrong

Every cell is empty only removes rows with nothing in them at all. Cells containing spaces count as empty here, since a row of spaces is a blank row for every practical purpose.

Any cell is empty is aggressive and usually a mistake on real data — most datasets have optional fields, so this will delete most of the file. It's the right choice only when you specifically need complete records, for instance before a load into a table where every column is NOT NULL. Watch the count.

Specific columns empty is the one you want most of the time: drop rows missing the key, keep everything else. It's also the honest alternative to filling gaps — if you can't fill a required field, dropping the row is better than inventing a value. Where a fill is appropriate, fill empty cells does it.

FAQ

Does it remove the trailing blank line at the end of the file?

A single trailing newline is treated as a file terminator, not a row, and never counts as an empty row. Output ends with one newline, which is what POSIX text tools expect.

Can it remove empty columns?

Not directly. Transpose, remove the now-empty rows here, then transpose back. For a column you can already name, delete columns is one step.

What counts as empty — is "0" empty?

No. Only a cell with nothing in it, or nothing but whitespace, is empty. 0, false, -, and N/A are all values. If a sentinel like N/A should be treated as missing, convert it to empty first with find and replace in a column.

What's the shell version?

grep -v '^[[:space:]]*$' f.tsv for fully blank lines, or awk -F'\t' '$1!=""' f.tsv to require the first column.

Privacy

100% client-side. No upload. See the privacy policy.