The code below is supposed to do as follows:
Fill an empty list with a specific column of numbers from a csv file.
The average of the list values is then calculated and the resulting value is plotted.
Problems: I keep getting the error "TypeError: cannot perform reduce with flexible type". All I do know is that it has to do something with condensing down a list. But I'm not sure beyond that. Any help is appreciated.
import csv
import matplotlib.pyplot as plt
import numpy as np
channelData = []
channelSel = int(input("Select a channel to view "))
with open('PrivateData.csv', newline='') as f:
reader = csv.reader(f)
for row in reader:
channelData.append(row[channelSel])
averagemV = np.mean(channelData)
plt.plot(averagemV)
plt.ylabel("Average mV")
plt.xlabel("Channel " + str(channelSel))
plt.show()
channelData? - KevinchannelSeltochannelData, you're appendingrow[channelSel], which might not necessarily have the same type aschannelSel. - Kevin