Skip to content

Instantly share code, notes, and snippets.

@tylercubell
Created April 27, 2018 10:34
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 tylercubell/66596161496054ffeb813fd85284a3ee to your computer and use it in GitHub Desktop.
Save tylercubell/66596161496054ffeb813fd85284a3ee to your computer and use it in GitHub Desktop.
import os, subprocess
# Remove null characters.
# http://gnuwin32.sourceforge.net/packages/coreutils.htm
file = "your_file_here"
command = ["C:\\Program Files (x86)\\GnuWin32\\bin\\tr.exe",
"-d \'\\000\'"]
with open(file, "r") as original, open(file + ".new", "w", encoding="utf-8") as modified:
subprocess.Popen(" ".join(command), stdin=original, stdout=modified).wait()
os.remove(file)
os.rename(file + '.new', file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment