Skip to content

Instantly share code, notes, and snippets.

@polotto
Last active October 18, 2019 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save polotto/c52a83e768e03c143a7d562f33034cdb to your computer and use it in GitHub Desktop.
Save polotto/c52a83e768e03c143a7d562f33034cdb to your computer and use it in GitHub Desktop.
#!/bin/python
# References:
# https://stackoverflow.com/a/15502713/6846888
# http://python-notes.curiousefficiency.org/en/latest/python3/text_file_processing.html
import os
import sys
path = os.path.dirname(__file__)
file_name = 'some_input_ansi_file.txt'
if __name__ == "__main__":
with open(os.path.join(path, './' + file_name), 'r', encoding='cp1252') as f1:
lines = f1.read()
f2 = open(os.path.join(path, './' + 'output_utf8_file.txt'), 'w', encoding='utf-8')
f2.write(lines)
f2.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment