tsvkit.org
TSV Toolkit
Sample data Say hi →

Fill Empty Cells in a TSV

constant · zero · forward / backward fill · mean · median

Two situations need this. One is honest: a spreadsheet export left the group label on only the first row of each group, so forward fill restores what was visually implied by the merged cell. The other needs care: a numeric column has gaps and something downstream can't handle nulls, so you substitute a value — which is a modelling decision, not a formatting one.

fill
Drop a .tsv file here, or
ready

How to use

  1. Paste or drop the file. Leave the columns field blank to fill everywhere, or name specific columns — usually what you want, since different columns need different treatment.
  2. Pick a method. Only cells that are empty or whitespace-only are touched; existing values are never overwritten.
  3. Check the fill count in the status line — if it's much larger than expected, the column had more gaps than you thought. Stats gives you the null count per column beforehand.

Forward fill: the merged-cell case

Previous value copies the last non-empty value down the column. This is the correct reconstruction of a spreadsheet where someone merged cells to show that a label applies to several rows — the label was only stored once, and forward filling restores what a human reading it would infer. Next value does the same upward, for the rarer layout where the label sits at the bottom of its block.

The one thing to check is that the file is still in its original order. Forward fill after a sort propagates values into rows they never belonged to, and there's nothing in the output to indicate it happened. Fill first, sort second.

Statistical fills: think before using

Mean and median are computed from the non-empty values in that column and substituted into the gaps. Both preserve the column's centre and shrink its variance, so any spread statistic computed afterwards is wrong — and nothing in the file records which values were invented. Median is the safer of the two on skewed data.

Zero is the most dangerous option, because zero is usually a meaningful value: filling a missing revenue with 0 asserts that no revenue occurred, which is a different claim from "we don't know". If the destination can hold nulls, leave the gaps alone. If it can't, a sentinel like N/A via this text at least stays visible as a marker, and removing the incomplete rows is often more defensible than filling them.

FAQ

Does it fill cells that contain spaces?

Yes — a cell of only whitespace counts as empty. If you need those preserved as-is, trim the file first with trim columns so you can see what's genuinely blank.

What happens to the first row if it's empty and I forward fill?

It stays empty — there's no previous value to copy. Same for the last row with a backward fill. Run both in sequence if you need every gap closed.

Can I fill different columns with different methods?

Run it more than once, copying the output back into the input each time. Forward-fill the label columns, then fill the numeric ones with a sentinel.

Are missing trailing cells filled too?

Yes — rows shorter than the header are padded out to full width first, and those new cells count as empty and get filled. If you'd rather see the raggedness than have it quietly fixed, check with the validator first.

Privacy

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