Created
October 6, 2014 14:56
-
-
Save oryband/d284df0f93e68a4e33e9 to your computer and use it in GitHub Desktop.
Copy & replace text from input file to output file.
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
#!/usr/bin/env python | |
"""Copy & replace text from INPUT_PATH to OUTPUT_PATH.""" | |
# Consts | |
REPLACE = ('\n', ' ', '\t') | |
REPLACE_WITH = (',') | |
INPUT_PATH = 'path/to/input.txt' | |
OUTPUT_PATH = 'path/to/output.txt' | |
if __name__ == '__main__': | |
with open(INPUT_PATH, 'rb') as input, open(OUTPUT_PATH, 'wb') as output: | |
data = input.read() | |
for char in REPLACE: | |
if char in data: | |
data = data.replace(char, REPLACE_WITH) | |
output.write(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment