How Can I Read Part Of File And Write The Rest To Another File?
I have multiple large csv file. How can I read part of each file and write 10% of the data/rows to another file?
Solution 1:
This works for me:
with open("in.csv") as infile, open("out.csv", "w") as outfile:
outcsv = csv.writer(outfile)
for i, row in enumerate(csv.reader(infile)):
if not i % 10:
outcsv.writerow(row)
Post a Comment for "How Can I Read Part Of File And Write The Rest To Another File?"