How to split a large CSV file into multiple files

Posted by Darwin Biler on October 28, 2012

So one day, someone gave you a CSV file (Comma-Separated Values). Then it needs to be uploaded to a website.
One of the major problem is, if the file is extremely huge (1 Gigabyte for example), most probably, you will hit the maximum file limit of the web server you are uploading that file into. Even if you adjust the maximum file limit, the problem is, the memory that will be consumed by the processing of that file is enormous. So one way to solve that problem is simple - split the huge CSV file into smaller fragments that the script can consume.

Here is how to do that, first download this file
csv-splitter-1.1.zip
Then, after extracting to your local disk, open it up

A window like this should appear

Basically, what that program does is, accept a file on the "CSV File" field (select by clicking the "Browse File" button)

Then decide how many lines per file you want via "Number of Lines" field
Then optionally, enter the maximum number of files to be generated via "Max Pieces" field

Hit the "Split Now" button to begin splitting the large CSV file, note that the script will create a folder in the same directory of the CSV file and save the splitted files there. That is, if you have a source CSV file in here
c:\GeoIPCountryWhois.csv
then a folder GeoIPCountryWhois.csv_Pieces will be created, then inside a series of
GeoIPCountryWhois_1.csv will be created, wherein the "1" is incremented as the number of each piece is created
so if you have a 10,000 lines of source csv file and you splitted it by 1000 each file, you will gonna have a 10 cs file in that folder starting from GeoIPCountryWhois_1.csv to GeoIPCountryWhois_10.csv, each with 1000 lines of data.

Credit : CSV splitter script written by user "scorpion" in this post http://www.fxfisherman.com/forums/forex-metatrader/tools-utilities/75-csv-splitter-divide-large-csv-files.html


Did you find this useful?

I'm always happy to help! You can show your support and appreciation by Buying me a coffee (I love coffee!).