Spaces:
Sleeping
Sleeping
File size: 492 Bytes
d737845 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# 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)
|