Reputation: 91
I am attempting to split a large 200,000 line csv file into smaller pieces using the terminal command:
split -l 20000 users.csv
From what I have read online this should chop up the 200,000 line csv into ten 20,000 line files but this doesn't happen. All I get is a text file called 'xaa' that is just the original csv, all 200,000 lines.
Like I said in the title I am running on Mac OS High Sierra v.10.13.5
What exactly am I missing here?
Upvotes: 0
Views: 1788
Reputation: 56657
As Ken Thomases points out in the comments, the most likely culprit is that the file is using non-newline line separators, and the most likely culprit is CR (carriage return).
You can tell if this is the case using the file
utility. A file with such line separators looks like this:
$ file foo
foo: ASCII text, with CR line terminators
The reason split
would behave this way with those line separators is that the file would appear to be only one line long (no newline characters). So split
would write that one (very long) line, then exit.
Upvotes: 4
Reputation: 4827
you should use the split command with the -b option. This will split your files based on kilobytes or megabytes. This may break up a line at the end but can manually be accounted for.
Upvotes: 0