Skip to content

Instantly share code, notes, and snippets.

@gautamk
Created December 27, 2015 05:04
Show Gist options
  • Save gautamk/543fb28a4fe0321e9a17 to your computer and use it in GitHub Desktop.
Save gautamk/543fb28a4fe0321e9a17 to your computer and use it in GitHub Desktop.
Convert the first line of all csv files in the current directory to lowercase
import glob
for filename in glob.iglob("*.csv"):
firstline = None
rest = None
with open(filename, 'r') as f:
firstline = f.readline().lower()
rest = f.read()
with open(filename,'w') as f:
f.writelines([firstline])
f.write(rest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment