Skip to content

Instantly share code, notes, and snippets.

@MartijnBraam
Created September 22, 2016 13:16
Show Gist options
  • Save MartijnBraam/48399e98bd05749ba612d7477a26735b to your computer and use it in GitHub Desktop.
Save MartijnBraam/48399e98bd05749ba612d7477a26735b to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
with open('test.dat', 'r', encoding="utf-8") as input_file:
with open('output.dat', 'wb') as output_file:
data = input_file.read()
data2 = data.encode('ascii', 'xmlcharrefreplace')
output_file.write(data2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment