Skip to content

Instantly share code, notes, and snippets.

@dqtweb
Created April 10, 2020 02:31
Show Gist options
  • Save dqtweb/fd3d23e8d86043f06a733fe9a0cb9cbb to your computer and use it in GitHub Desktop.
Save dqtweb/fd3d23e8d86043f06a733fe9a0cb9cbb to your computer and use it in GitHub Desktop.
Add UTF-8 support to csv content file
# so that you can open with excel
def addUTF8Bom(filename):
f = codecs.open(filename, 'r', 'utf-8')
content = f.read()
f.close()
f2 = codecs.open(filename, 'w', 'utf-8')
f2.write(u'\ufeff')
f2.write(content)
f2.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment