Easily Split CSV File in Python for Split-Testing

avatar

For work I needed to send batches of emails from a ~600,000 long customer email list.

Here is the quick python script I threw together (change 300000 and 400000 to suit).

import csv

count = 0
with open('users.csv') as csvfile:
    reader = csv.reader(csvfile, delimiter=',', quotechar='"')
    for row in reader:
        count=count+1
        if(count > 300000):
            if (count < 400000):
                print(','.join(row))
            else:
                break
print(count)




0
0
0.000
0 comments