0

I have a large csv file I want to split in two, but keep the same header.

First part is easy:

tmp = pandas.read_csv("bigcsv.csv", nrows=50000)     
tmp.to_csv("newcsv1.csv")

So I create a newcsv1 file which has the first 50000 rows of the original csv file. Second part I thought I could do:

tmp = pandas.read_csv("bigcsv.csv", header=0, skiprows=50001, nrows=50000)
tmp.to_csv("newcsv2.csv")

but in the second file I don't get the same header, it creates as header what was at line 50000. I want the same header as the original file.

It should be easy, but how do I do it?

user
  • 2,015
  • 6
  • 22
  • 39

0 Answers0