Created
July 9, 2014 16:31
-
-
Save Achifaifa/630246e7db691b90ec1a to your computer and use it in GitHub Desktop.
Simple file to automatically add commas to MySQL .csv dumps. Use python comas.py [filename]. CSV file must be in the same directory. Output in ./comas_out
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 | |
import sys | |
if __name__=="__main__": | |
try: | |
path="./"+sys.argv[1] | |
except: | |
print "Use: python comas.py [filename]" | |
print "Wrong syntax or file not found" | |
try: | |
with open (path,"r") as infile: | |
with open ("./comas_out","w+") as outfile: | |
for line in infile: | |
if "0"<=line[0]<="9": outfile.write(line.strip()+",") | |
except: | |
print "File error" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment