Trying to write a python script that reads a csv file and prints an x-y plot. I have a csv file with a few rows and columns worth of data. I'd like to plot an x-y plot for the first and second column. Here is what I've got so far...
import csv
def getColumn(filename, column):
results = csv.reader(open(filename), delimiter="\t")
return [result[column] for result in results]
x = getColumn("TableOne.csv",0)
y = getColumn("TableOne.csv",1)
plt.figure("X-Y Plot")
plt.xlabel("Site")
plt.ylabel("Average")
plt.plot(x,y)
... but it's reading my csv file by row, not column, which outputs a bunch of mixed data instead of the one specific data I want. Any suggestions?