My program was working perfectly; then, it would give me an error that states the following:
Traceback (most recent call last):
File "K:\56_CRT\1 PST EEIC\2_Projects\InternetOfTests\Project_Jacob\Full
Program (Testing).py", line 228, in <module>
inputSamplesm[idx] = [data[0], data[1]]
IndexError: list index out of range
I don't know what that is. I've been trying to manipulate the arrays and indices, but I seem to fail to solve the problem. Please advise. Find my code below:
with open('MagnaDC Set Points.csv', 'r') as csvfile1, open('Amatek Set Points.csv', 'r') as csvfile2:
dataset = csv.reader(csvfile1, csvfile2, delimiter=',')
next(dataset)
rows = list(dataset)
inputSamplesm = np.empty([len(rows), 2], dtype=float)
outputSamplesm = np.empty([1,3], dtype=float)
inputSamplesa = np.empty([len(rows), 2], dtype=float)
outputSamplesa = np.empty([1,3], dtype=float)
testStartTime = time.time()
for idx, data in enumerate(rows):
inputSamplesm[idx] = [data[0], data[1]]
inputSamplesa[idx] = [data[0], data[1]]
s.sendall('VOLT {0}\n'.format(data[0]).encode('utf-8'))
conn.write('VOLT {0}\n'.format(data[0]).encode('utf-8'))
stopTime = testStartTime + int(data[1])
while time.time() < stopTime:
s.sendall('MEAS:VOLT?\n'.encode('utf-8'))
voltm = s.recv(1024)
voltm = float(voltm)
IndexError: list index out of rangemeans that the index you are trying to access does not exist. So, eitherinputSamplesm[idx],data[0]ordata[1]does not exist.inputSamplesmanddataand check whether your indexes exist. Honestly, no need to ask a question for this.readerfunction. Indataset = csv.reader(csvfile1, csvfile2, delimiter=',')content of csvfile1 may be empty or not delimited by,