How to split a large text file into parts of your choosing:
- by line number;
- by file size (Kb or Mb);
- or even based on an arbitrary regular expression (how cool is that?).
Example: auto split one large CSV file into files of 200 lines each
Let's say I have a file that I want to split into multiple files that contain a maximum of 200 lines. I can use the following command:
split -l 200 {example}.csvWhere '{example}.csv' is the filename of the CSV file you wish to split into chunks of 200 lines. The split function itself is smart enough to give the new files a name, but it doesn't add an extension.
If you want to add an extension to the new files (for example: '.csv'), you can do that manually in Finder (by selecting all files, and change the name), or do it automagically with another Terminal command:
for i in *; do mv "$i" "$i.txt"; done
Make sure you got this right
You should know this, but just to make sure:
- open the Terminal in the right folder;
- make sure that it's ok to add the extensions to all files in the folder;
- and last but not least: make sure that Mac OS X can open and read the original .CSV file;
TL;DR version

Care to respond?
Thank you! You can use your fave social network:
Or respond to me personally. For example by calling me: +31626414088, via Skype, or .(JavaScript must be enabled to view this email address).