Answer the question
In order to leave comments, you need to log in
How to write Cyrillic to CSV in Python?
Hello everyone, I've encountered writing Cyrillic in a CSV file. there is this code:
# -*- coding: utf-8 -*-
....
with open(filename, 'w+', encoding='utf8', newline='') as file:
writer = csv.writer(file, delimiter=';')
count_elements = len(data['urls'])
for i in range(1, count_elements):
writer.writerow([
data['titles'][i],
data['titles'][i],
int(data['costs'][i]),
data['address'][i],
data['urls'][i],
])
Answer the question
In order to leave comments, you need to log in
with open(filename, 'w+', encoding='utf8', newline='')
replace
with with open(filename, 'w+', newline='')
or
with open(filename, 'w+', encoding='cp1251 ',newline='')
Take note of the encoding you are using:
encoding='utf8'
Take note of this question . There is an answer there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question