Skip to content

Instantly share code, notes, and snippets.

@dmnc-net
Created July 31, 2012 08:18
Show Gist options
  • Save dmnc-net/3214869 to your computer and use it in GitHub Desktop.
Save dmnc-net/3214869 to your computer and use it in GitHub Desktop.
fixed width text file to CSV converter
#!/usr/bin/python
import sys
import csv
rf = open(sys.argv[1]) #input file handle
wf = open(sys.argv[2],'w') #output file handle
writer = csv.writer(wf)
for row in rf.readlines():
writer.writerow(row.split())
rf.close() # close input file handle
wf.close() # close output file hanle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment