Skip to content

Instantly share code, notes, and snippets.

@ionatan-israel
Last active March 6, 2021 19:16
Show Gist options
  • Save ionatan-israel/996b8804b59268ab2192 to your computer and use it in GitHub Desktop.
Save ionatan-israel/996b8804b59268ab2192 to your computer and use it in GitHub Desktop.
Cambiar codificación de caracteres de un archivo con python.
# -*- coding: utf-8 -*-
file = 'file.csv'
outfile = 'out.csv'
f = open(file, 'rb')
# Windows Comma Separated (.csv) ~ ISO-8859-2 | CP1252
content = unicode(f.read(), 'CP1252')
f.close()
out = open(outfile, 'wb')
out.write(content.encode('utf-8'))
out.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment