I'm trying to make a plot from some data but I get an index out of range error even though the data has 2 columns. Here's the code:
import csv
from matplotlib import pyplot as plt
def getColumn(filename, column):
results = csv.reader(open(filename), delimiter='\t')
return [result[column] for result in results]
wavelength = getColumn('Bb69.dat.fix',0)
flux = getColumn('Bb69.dat.fix',1)
plt.figure('Bb69')
plt.xlabel('Wavelength (angstrom)')
plt.ylabel('flux (erg/cm^2/s/angstrom)')
plt.plot(wavelength,flux)
plt.show()
Here is the error
Traceback (most recent call last):
File "SP12.py", line 14, in <module>
flux = getColumn('Bb69.dat.fix',1)
File "SP12.py", line 11, in getColumn
return [result[column] for result in results]
IndexError: list index out of range