Answer the question
In order to leave comments, you need to log in
How to split csv file line by line into many files?
There is a file in csv format, let's say it has 1000 lines and 2 columns. Q: How can this file be divided into 1000 files, i.e. line by line?
Answer the question
In order to leave comments, you need to log in
It is possible in Python:
with open('data.csv') as file:
lines = file.read().splitlines()
def write_line(filename, line):
with open(filename+'.csv','w') as file:
file.write(line)
for i,line in enumerate(lines):
write_line(str(i),line)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question