Spaces:
Sleeping
Sleeping
# data preprocess | |
import csv | |
news = [] | |
## Read csv file from news.csv | |
with open('news.csv', 'r', encoding='utf-8-sig') as f: | |
reader = csv.DictReader(f) | |
for row in reader: | |
news.append({ | |
'title': row['Title'], | |
'content': row['Content'] | |
}) | |
with open('news.txt', 'w', encoding='utf-8') as f: | |
for n in news: | |
f.write(n['title'] + '\n') | |
f.write(n['content'] + '\n') | |
f.write('\n') | |
f.write('\n') | |
print(n) | |