ToolsBlog

How to Split a Large CSV File into Multiple Files

Try it free:CSV SplitterCSV CompressorCSV to Parquet Converter

Table of Contents

  • Option 1: split it in your browser
  • Option 2: the split command (macOS and Linux)
  • Option 3: DuckDB
  • Option 4: Python and pandas
  • Which method should you use?
  • Do you need to split it at all?
  • FAQ
  • How do I split a CSV file into multiple files with the header?
  • How many rows can Excel open?
  • Can I split a CSV by file size instead of rows?
  • How do I split a CSV on Windows?
  • How do I combine the files again?

A CSV that is too big to open, upload or email becomes manageable once it is cut into smaller pieces. The usual reasons:

  • Excel stops at 1,048,576 rows. Anything past that is not loaded.
  • Upload forms and APIs have size limits, such as 25 MB or 100 MB per file.
  • Imports time out on one huge file but succeed on several small ones.

Splitting a CSV correctly means two things: every part should start with the header row, and no row should be cut in half. This guide shows four methods, from no setup at all to a script, and points out where each one can go wrong.

Option 1: split it in your browser #

The CSV Splitter splits the file on your own device. Nothing is uploaded, and there is nothing to install.

  1. Open the CSV Splitter and choose your .csv, .tsv or .txt file.
  2. Pick a split mode: Rows per file (for example 500,000) or Approximate size per file in MB.
  3. Leave Repeat the first row as a header in every split file switched on, so each part works on its own.
  4. Click Split CSV, then Download All as ZIP or download the parts one by one.

Parts are named after the original file, such as sales-part-001.csv, sales-part-002.csv. The splitter streams through the file and keeps the parts in browser storage on disk rather than in memory, so it handles files far larger than a spreadsheet can open. It parses CSV properly: a quoted value that contains a line break stays in one piece, in one part. One split can create up to 1,000 parts; if your settings would produce more, it suggests a bigger row count or size.

If your file is compressed (.csv.gz or .zip), decompress it first. If it is an Excel workbook, convert the sheet with the Excel to CSV converter and split the result.

Option 2: the split command (macOS and Linux) #

The split command splits any text file by line count. It does not know about CSV headers, so you remove the header, split the rest, and add the header back to each part:

# 1. Split everything except the header into 100,000-line pieces
tail -n +2 big.csv | split -l 100000 -d - part_

# 2. Put the header back on each piece and add the .csv extension
for f in part_*; do
  { head -n 1 big.csv; cat "$f"; } > "$f.csv" && rm "$f"
done

This produces part_00.csv, part_01.csv and so on, each starting with the header. It works with the split that ships with both macOS and Linux. (-d asks for numeric suffixes; without it you get part_aa, part_ab.)

It is very fast, but it has one real limitation: split counts lines, not CSV records. If a quoted field contains a line break, such as an address or a comment, that record spans two lines. It may be cut in half at a part boundary, and the line counts will not match the row counts. If your data has multi-line values, use one of the other methods.

Option 3: DuckDB #

DuckDB is a free, single-file SQL engine (brew install duckdb, winget install DuckDB.cli). It reads the CSV with a real parser and writes the parts with a header in each one.

By approximate file size:

COPY (SELECT * FROM read_csv('big.csv', all_varchar = true))
TO 'parts_by_size' (FORMAT csv, FILE_SIZE_BYTES '100MB');

This creates a folder parts_by_size containing data_0.csv, data_1.csv and so on, each about 100 MB.

By row count:

COPY (
  SELECT *, (row_number() OVER () - 1) // 100000 AS part
  FROM read_csv('big.csv', all_varchar = true)
)
TO 'parts_by_rows' (FORMAT csv, PARTITION_BY (part));

This writes parts_by_rows/part=0/data_0.csv, part=1/data_0.csv and so on, with 100,000 rows in each. The helper part column decides the folder and is not written into the files.

all_varchar = true reads every value as text, so values like ZIP codes with leading zeros or dates come out exactly as they went in.

DuckDB can also split by a column's values: PARTITION_BY (country) writes one folder per country. That is often more useful than an arbitrary row count.

Option 4: Python and pandas #

If you already use Python, pandas can read the file in chunks so it never loads the whole CSV into memory:

import pandas as pd

rows_per_file = 100_000
chunks = pd.read_csv("big.csv", dtype=str, chunksize=rows_per_file)

for i, chunk in enumerate(chunks):
    chunk.to_csv(f"part_{i:03}.csv", index=False)

Each part_000.csv, part_001.csv and so on gets the header and up to 100,000 rows. Keep dtype=str: without it pandas converts columns to numbers, so 01234 becomes 1234, and integer columns with blank cells come back as 1234.0.

Which method should you use? #

Situation Best option
One file, right now, no installs CSV Splitter
Sensitive data you cannot upload Any of the four: all run locally
Simple data, no line breaks inside values split
Split by size, or by a column such as region DuckDB
Part of a larger Python pipeline pandas

Do you need to split it at all? #

Splitting is the right fix when something downstream has a hard limit. If you only need to read or query the data, there are alternatives:

  • To look at the rows, open the file in the CSV editor or query it with SQL in Query CSV with SQL.
  • To make the file smaller to send, compress it with gzip, which often makes a CSV several times smaller.
  • To keep one file that loads fast in analytics tools, convert it to Parquet.

FAQ #

How do I split a CSV file into multiple files with the header? #

Use the CSV Splitter with the header option on, the tail + split + loop recipe above, DuckDB's COPY ... PARTITION_BY or pandas with chunksize. All four write the header into every part.

How many rows can Excel open? #

1,048,576 rows per sheet, including the header. Split larger CSVs into parts below that, for example 1,000,000 rows each.

Can I split a CSV by file size instead of rows? #

Yes. Choose Approximate size per file in the CSV Splitter, or use DuckDB's FILE_SIZE_BYTES. Sizes are approximate because rows are never cut in half.

How do I split a CSV on Windows? #

The CSV Splitter runs in any browser on Windows. DuckDB and Python also run on Windows; the split command does not ship with it.

How do I combine the files again? #

In DuckDB, this reads every part and writes a single CSV with one header:

COPY (
  SELECT * FROM read_csv('parts_by_rows/*/*.csv', all_varchar = true, hive_partitioning = false)
) TO 'combined.csv';

hive_partitioning = false stops DuckDB from adding the part folder name back as a column.

Try the tools from this post

Free and private: your files stay in your browser.

  • CSV SplitterSplit large CSV files into smaller browser-friendly chunks locally.
  • CSV CompressorSave space and improve performance with our CSV Compressor.
  • CSV to Parquet ConverterConvert CSV files to compressed parquet. Ideal for efficient storage and analytics.

Related posts

How to Make CSV Files Smaller with GZIP Compression

Learn how to compress CSV files to make them smaller and more efficient.

2024-10-09

Why CSV is King

Why CSV is King: Areas where it excels

2024-08-25

Converting a 177M-row CSV to Parquet: A Deep Dive

Explore large CSV to Parquet conversion, with insights on performance, compression, and data management best practices.

2024-08-14

ChatDB

Free, browser-side data tools. No uploads, no accounts.

Data tools

Reader

  • Online CSV Viewer
  • Parquet Viewer & Reader
  • Excel Viewer and Editor
  • SQLite Viewer
  • Gzip CSV Reader
  • CSV Size Analyzer
  • Parquet Schema Reader
  • Parquet Metadata Reader
  • Data Profiler
  • Image Measure
  • Shapefile Viewer
  • GeoJSON Viewer

Editor

  • CSV Viewer and Editor
  • Excel Viewer and Editor
  • Online Excel Editor
  • CSV Splitter
  • Markdown Editor
  • Image Cropper
  • SVG Editor
  • Screenshot Background Creator
  • Document Scanner
  • Audio Clipper
  • Video Trim & Crop Tool

Converter

  • CSV to Gzip Converter
  • CSV to Parquet Converter
  • Excel to CSV Converter
  • Parquet to CSV Converter
  • JSON to Parquet Converter
  • Parquet to JSON Converter
  • CSV Decompressor
  • CSV to JSON Converter
  • CSV to Markdown Table
  • Image Converter
  • KML to GeoJSON Converter
  • GPX to GeoJSON Converter
  • GeoJSON to KML Converter
  • Shapefile to GeoJSON Converter

Formatter

  • CSV Encoder
  • SQL Formatter
  • JSON Formatter
  • XML Formatter
  • YAML Formatter
  • Dataset README Generator
  • URL Encoder & Decoder
  • Regex Tester

Compressor

  • CSV Compressor
  • CSV to Gzip Converter
  • CSV Decompressor
  • Image Compressor

AI

  • Parquet AI
  • CSV AI
  • Color Palette Generator
  • Extract Image Colors

GIS

  • Lat/Lng Point Finder
  • KML to GeoJSON Converter
  • GPX to GeoJSON Converter
  • GeoJSON to KML Converter
  • Shapefile to GeoJSON Converter
  • Shapefile Viewer
  • GeoJSON Viewer

Image tools

Convert To

  • Convert to JPEG
  • Convert to PNG
  • Convert to WEBP
  • Convert to GIF
  • Convert to BMP
  • Convert to TIFF
  • Convert to ICO
  • Convert to AVIF
  • Convert to FF
  • Convert to HDR
  • Convert to EXR
  • Convert to QOI
  • Convert to TGA
  • Convert to PNM

Edit

  • Image Cropper
  • SVG Editor
  • Screenshot Background Creator
  • Document Scanner

Compress

  • Compress JPG
  • Compress JPEG
  • Compress PNG
  • Compress WEBP
  • Compress GIF

Company

  • All tools
  • Blog
  • Privacy Policy
  • Terms of Service

© 2026 ChatDB. All rights reserved.

v2.4.1