Rowlode
EN
EnglishEspañolPortuguêsFrançais

Count the rows in a large CSV file

Before importing or splitting a big CSV you usually want one number: how many records? Line-counting commands are fast but can be wrong.

Updated 2026-10-26 · 4 min read

Quick line counts

  • macOS/Linux: wc -l file.csv
  • Windows PowerShell: $n=0; foreach($l in [IO.File]::ReadLines("C:\data\file.csv")){$n++}; $n (streams the file; Get-Content | Measure-Object is much slower on big files)

Subtract 1 for the header row.

Why the line count can be wrong

  • A quoted field can contain line breaks (addresses, comments). Each one adds a line but not a record.
  • A file without a final newline makes wc -l report one less.
  • Blank lines at the end are counted as lines.

Exact count (CSV-aware)

Python: import csv; print(sum(1 for _ in csv.reader(open('file.csv', newline='', encoding='utf-8'))) - 1). Or open the file in Rowlode: it parses quotes and embedded newlines properly, skips blank lines, reports irregular rows, and shows the exact row count as soon as indexing finishes – plus per-column filled/empty counts in the column statistics.

Have a big or messy CSV? Rowlode opens CSV files with millions of rows (multi-GB) in your browser, reading them from disk – filter, remove duplicates, sort, fix delimiter and encoding, and export CSV, Excel (split under the row limit), TSV, JSON or NDJSON. Nothing is uploaded. Viewing, filtering and dedupe are free; each export holds the first 10,000 rows until you buy a $12 lifetime license.

Open Rowlode – free

Questions and answers

How long does counting take?

Line counting reads the whole file once – roughly disk speed. Rowlode indexed a 2-million-row, 144 MB file in about a second in testing; multi-GB files take tens of seconds.

Can I count rows matching a condition?

Yes: apply a filter in Rowlode and the result count updates; on the command line use grep -c for simple text matches.

Sources and product names: GNU coreutils wc documentation; Python csv module documentation; RFC 4180 (CSV with quoted line breaks). Microsoft Excel and Power Query are trademarks of Microsoft; Google Sheets is a trademark of Google. Rowlode is independent and not affiliated with them.