D
D
Dmitry2020-12-26 22:20:04
Python
Dmitry, 2020-12-26 22:20:04

Python Can't save csv as utf-8?

Bottom line: I need to get a table from the site and save it in csv format, but I can't do it in utf 8 encoding.
The code is simple:

import pandas as pd

tables = pd.read_html('https://kody-smajlov-vkontakte.ru/')
db = tables[1]
db.to_csv("data.csv", encoding = 'utf-8')

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
John Rosed, 2020-12-27
@idontgetit

df.to_csv("data.csv", encoding = "utf-8-sig")

A
Alex F, 2020-12-27
@delvin-fil

Try:

import locale
locale.setlocale(locale.LC_ALL, 'UTF-8')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question