M
M
maximich_0172018-08-17 14:25:19
MySQL
maximich_017, 2018-08-17 14:25:19

How to get rid of UnicodeEncodeError?

I import data from a CSV file into Mysql 5.7. UTF-8 file. Base UTF-8. script python 3.6.6 - utf-8
Django 1.11.15
on some records (approximately 25 out of 5000) import error UnicodeEncodeError: 'utf-8' codec can't encode characters in position 16-27: surrogates not allowed at the moment query execution using django orm
Which way to dig?
attempts to mystr.encode(errors='ignore') result in a message that a byte object is expected and not a string.
On the dev server, the error is not reproduced. There Mariadb 10.1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2018-08-17
@fox_12

Try reading the file via codecs.open

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question