# Stephanie Taylor # Fall 2015 # Use this program to fix up files that have the wrong # end-of-line character. It will rewrite the file (with the same name) # with the fixed up characters. # Call it like this: # python fixupEOL.py # where should be the name of your .csv or .txt file # for example # python fixupEOL.py tree_data.csv import sys if len( sys.argv ) < 2: print "USAGE: python fixupEOL.py " print " where should be the name of your .csv or .txt file" print "for example" print "python fixupEOL.py tree_data.csv" filename = sys.argv[1] f = file( filename ) lines = f.readlines() if len(lines) == 1: lines = lines[0].split( '\r' ) f.close() f = file( filename, 'w' ) for line in lines: f.write( line + '\n' ) f.close()