I have a csv file in excel that contains 2000 rows of data. I would like to output 100 lines of the data to different text files. However I have no idea of how to do this. All I can do is output the file into a single file. I have read the CSV file data in Python Pyscripter and then wrote the file to a single file like this:
def read_csv(self):
with open(self.data, newline='') as f:
reader = csv.reader(f)
for row in reader:
self.content.append(row)
def write_txt(self):
f = open(self.txtoutput, 'w')
for row in self.content:
f.write(', '.join(row) + '\n')
f.close()
However, I would like each 100 rows of the 2000 row data to be outputted to different text files.Can anyone point me to the right direction. Note:I am using Python3. Thanks in advance.