Guest User

Untitled

a guest
Jan 16th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. def to_csv():
  2. with open('data_set.csv', 'w', newline='', encoding='utf-8') as csvfile:
  3. translator = str.maketrans('', '', string.punctuation)
  4. writer = csv.writer(csvfile, delimiter=',')
  5. rows = []
  6. for i in range(1, 1):
  7. try:
  8. file = open("false_text_files/" + str(i) + ".txt", "rb")
  9. text = file.read().decode().translate(translator)
  10. except:
  11. continue
  12. row = ['no', text]
  13. rows.append(row)
  14. for u in rows:
  15. print(u[1])
  16. writer.writerow(u)
Add Comment
Please, Sign In to add comment