0

I want to use split to break a 5 GB CSV file into multiple files. I am testing if the split command works on a smaller file, so I created a CSV file named test with the following information:

Name    Age Blah
bob 12  x
sam 32  x
x   x   x
x   x   x
x   x   x
x   x   x
x   x   x
x   x   x
x   x   x

I run:

split -l 2 test2.csv

And I would expect five or more files created named xaa, xab, etc. Instead I am seeing one file with all the rows named xaa. I also tried doing it with gsplit and I got the same result.

Any suggestions on how to debug or how to get it to work? I am assuming this is failing silently.

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
  • The data came out wrong, but essentially I have a 3x10 csv file (3 columns, 10 rows) – Andrés Egoavil Mar 18 '16 at 01:47
  • It works for me here with `split` from GNU Coreutils 8.24... do you use an odd `split`? – Benjamin W. Mar 18 '16 at 03:28
  • Do you use confusing line endings? What does `wc -l` show for the input file? – Benjamin W. Mar 18 '16 at 03:30
  • Hey Ben - I use the split that is available on the mac terminal, but I also installed the GNU coreutils one and I have the same issue. This is the output for wc -l on the file: > wc -l test2.csv 0 test2.csv – Andrés Egoavil Mar 18 '16 at 12:28
  • This means that your shell doesn't see any line endings; try removing carriage returns as per for example this question: http://stackoverflow.com/questions/800030/remove-carriage-return-in-unix – Benjamin W. Mar 18 '16 at 13:12

0 Answers0