SmartQueryTools

Extract Tail of CSV Files Online

Extract the last N rows from CSV files directly in your browser. Choose how many rows to keep and download the result — no upload required.

How to extract Tail of CSV files

  1. Drop your file onto the upload area. The total row count is shown and the first 200 rows are previewed.
  2. Enter how many rows to keep from the end in the Number of rows box. The default is 100.
  3. Click Extract Last Rows. The preview switches to the final rows of the file, in their original order.
  4. Click Download to save them in the same format you uploaded, with _tail added to the file name.

Your file is processed locally in your browser and is never uploaded. The free limit is 50 MB per file; larger files work if your device has the memory for them.

Worked example

A leisure centre appends every member check-in to a single export. The front desk manager only wants the two most recent visits to check a disputed entry.

Input (CSV)

member_id,check_in_date,branch,minutes
M-2031,2026-08-28,Riverside,55
M-1177,2026-08-29,Old Town,40
M-2031,2026-08-30,Riverside,62
M-0948,2026-08-31,Riverside,
M-1177,2026-09-01,Old Town,35
M-3310,2026-09-01,Riverside,90

Settings

  • Number of rows: 2

Result

member_idcheck_in_datebranchminutes
M-11772026-09-01Old Town35
M-33102026-09-01Riverside90

The file has six rows, so the tool skips the first four and keeps rows five and six. They stay in file order, oldest first, rather than being reversed. The tool does not look at check_in_date at all. It only works because new check-ins were appended to the bottom of the file.

Working with CSV files

CSV exports from logging and ticketing systems are usually appended to, so the last lines are the newest. The tool counts every data row, then skips all but the last N. The header is not a data row and is always written at the top of the result, so you never lose the column names the way you can with a plain tail -n on the command line.

A trailing empty line at the end of the CSV is ignored and does not count as a row. A final line with only commas, such as ,,, is a real row of empty values and will appear in the output. The result is rewritten as comma-separated text with LF line endings, and columns that were detected as numbers or dates are written in a standard form rather than the original characters. For a log that grows every day, set N to roughly one day of rows to pull just the newest batch, without opening the whole file in a spreadsheet.

Frequently Asked Questions

Does the tail of a CSV include the header?

Yes. The header is kept at the top of the output. N counts data rows only.

My CSV ends with a totals line. How do I leave it out?

Take the tail with one extra row, then use the Filter tool to remove the totals line by its label. Or take the head of the file with one row fewer than the total to drop it.

Are the last rows returned newest first?

No. They keep the order they have in the file. The last row of the file is the last row of the result.

Does Tail sort by date before taking the last rows?

No. It uses file position only. To get the latest N records by a date column, sort by that column first and then take the tail, or use the Sort tool followed by Head.

What if N is larger than the number of rows?

You get the whole file. An empty or non-numeric value falls back to 100. 0 and negative numbers are treated as 1, so you always get at least one row.

Related Tools