Your file lines seem to be encoded in Windows-1250. Your database seems to contain UTF-8 rows.
So you can convert all strings to unicode first:
codes_from_file = [a.decode("windows-1250") for a in codes_from_file] kode_prfoksov] = [a.decode("utf-8") for a in codes_from_file]
or if you don't want a unicode string, just convert the file string to UTF-8:
codes_from_file = [a.decode("windows-1250").encode("utf-8") for a in codes_from_file]
jofel source share