What I'm trying to do is basically reading a csv file to a list, ( one column only ). Then I need to read 11 elements ( one element = 9 digit number ) from the list, with comma, to a row with newline. All goes into another text file. 11 elements i a row match a A4 sheet. Then iterate over remaining elements in the list. I can't figure out how. Below follows my code I'm working on:
count = 0
textfile = 'texstf.txt'
filepath = 'testfile2.csv'
with open(filepath, "r") as f:
lines = [ str(line.rstrip()) for line in f ]
for key in lines:
while(count < 11):
with open(textfile, "w") as myfile:
myfile.write(','.join(lines))
count += 1
csv sample:
6381473
6381783
6381814
...
expected output to file sample:
6381473,6381783,6381814