I am looking to see if I can find a more efficient way to write this. The problem with csv reader is that when you write the output to standard out it tosses additional single quotes around it. Changing the quotes to none didn't help because it didn't retain formatting.
This code works but I have a feeling that I could do it more efficiently. I am really new to python and programming.
import csv
import sys
def printString(x):
print x[0] + ",", x[1] + ",", x[2] + ",", x[3] + ","
with open(sys.argv[1],"rb") as inputFile:
csvInput = csv.reader(inputFile, delimiter=',')
header = next(csvInput)
sort = sorted(csvInput, key=lambda x:float(x[3]))
printString(header)
for i in sort:
printString(i)