How to write UTF-8 in a CSV file

It’s very simple for Python 3.x (docs).

import csv

with open('output_file_name', 'w', newline="", encoding='utf-8') as csv_file:
    writer = csv.writer(csv_file, delimiter=";")
    writer.writerow('my_utf8_string')

For Python 2.x, look here.

Leave a Comment