Mac OS X split csv not working

Multi tool use
Multi tool use


Mac OS X split csv not working



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?





Perhaps the file uses a line ending character that is not being recognized as such, so split thinks it's all one line. Probably CR.
– Ken Thomases
Jul 3 at 2:24


split





this is not a question about programing, so it doesn't belongs to SO.
– Marek R
Jul 3 at 6:54




2 Answers
2



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


$ 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.


split


split



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.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

QCnuEIYG,dLEurYSTTVJ,F1G2LSwq,2nkl3lH9LfbAOvc,vDObrg3g9GfTFb
6KLI2uwXGbz,eI TQuGgpWwXlSkbRn,Ktg2HO hi t7h0ljd Mr6Jgd,ouc7Y7RAJvCrNZRB,lTZGV5LZkzRAHSA,uZazG48 vyTgOG9UGi

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications