For some reason I am getting this error when trying to run the following code
#!/usr/bin/python
import matplotlib.pyplot as plt
x = []
y = []
readFile = open('Out_0_0.txt','r')
sepFile = readFile.read().split('\n')
readFile.close()
for plotPair in sepFile:
xandy = plotPair.split()
x.append(int(xandy[0]))
y.append(int(xandy[1]))
print x
print y
When I remove the x.append and y.append lines and just put a print statement to print out what is in xandy it prints out each pair of values in the arrays fine. The text file has this
1 2
3 4
5 6
7 8
all I want it to do is store the first column in the x array and the second column in the y array
.readwill automatically read the lines one at a time. Do you maybe mean to do.readlines?x = [1, 3, 5, 7]andy = [2, 4, 6, 8]