Using Python 3.6 on Windows 10.
def to_csv():
with open('data_set.csv', 'w', newline='', encoding='utf-8') as csvfile:
translator = str.maketrans('', '', string.punctuation)
writer = csv.writer(csvfile, delimiter=',')
rows = []
for i in range(1, 190):
try:
file = open("false_text_files/" + str(i) + ".txt", "rb")
text = file.read().decode().translate(translator)
except:
continue
row = ['no', text]
rows.append(row)
for u in rows:
print(u[1])
writer.writerow(u)
For several entries, the text element is being split and added to the next line of the CSV file. e.g.
The text contains no punctuation so I cannot work out why it is being split between two lines. Any help or advice as to what could be going wrong would be greatly appreciated.