The loader takes 50,000 rows at a time

DataFileSplitter » Use cases » Split for a fixed batch size

Download DataFileSplitter Free Trial »     Buy DataFileSplitter Now »

The situation

Something downstream takes a fixed batch: a bulk loader that imports 50,000 records per run, an API that accepts 10,000 objects per request, an upload form that caps a file at a certain number of rows. The export you have is one file with a million rows in it.

Cutting it by file size is the wrong tool here - bytes per file say nothing about rows per file, and a part that happens to contain 50,001 rows still fails. What is needed is a split by record count.

What you do

  1. Choose the file and set the number of records per output file - for example 50,000.
  2. Run the split. Every output file holds exactly that many records, and the header is repeated so each part is a complete, importable file on its own.
  3. Feed the parts to the loader in order.

Splitting a CSV file by record count with DataFileSplitter

The result is flat and predictable: no part is bigger than the limit, every part has the same shape as the original, and the parts are roughly equal in size. For JSON and XML the same setting splits by object or element count instead of rows, and each output document stays well formed.

What it will not do

Related

Splitting by count: split by record/object count. Splitting by value instead: split by column value, split JSON by column value. Loading the parts: FileToDB. In the browser: split CSV, split TXT.