Last active
August 29, 2015 13:57
-
-
Save orliesaurus/9431320 to your computer and use it in GitHub Desktop.
Remove Escape Chars from text file in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Usage: python thisfile.py "path/to/file.txt" > cleanfile.txt | |
import re | |
import sys | |
with open(sys.argv[1]) as fp: | |
for line in fp: | |
newline = re.sub(r'\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]', "", line) | |
print newline |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment