Created
September 7, 2017 20:44
-
-
Save iandewancker/58c8e684e3120ebe139fd7ab951a9c8a to your computer and use it in GitHub Desktop.
Replace CSV header names in place
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
def replace_dot_header(file_name): | |
with open(file_name, 'r+b') as f: | |
line = next(f) # grab first line | |
old = '.' | |
new = '_' | |
f.seek(0) # move file pointer to beginning of file | |
f.write(line.replace(old, new)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment