Skip to content

Instantly share code, notes, and snippets.

@iandewancker
Created September 7, 2017 20:44
Show Gist options
  • Save iandewancker/58c8e684e3120ebe139fd7ab951a9c8a to your computer and use it in GitHub Desktop.
Save iandewancker/58c8e684e3120ebe139fd7ab951a9c8a to your computer and use it in GitHub Desktop.
Replace CSV header names in place
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