i am learning matplotlib python. but there is same problem in this program
import matplotlib.pyplot as plt
x = []
y = []
readf = open('data.txt', 'r')
splitdata = readf.read().split('/n')
readf.close()
for plotpair in splitdata:
xandy = plotpair.split(',')
x.append(int(xandy[0]))
y.append(int(xandy[1]))
plt.plot(x, y)
plt.title('the X title')
plt.xlabel('the x label')
plt.ylabel('the y label')
plt.show()
and data file same dir or valuse is this..
10101,9
93845,8
94847,4
49948,3
85768,5
57684,2
74859,1
93847,6
but error is
Traceback (most recent call last):
File "/home/najeeb/PycharmProjects/matplot-read-file.py", line 16, in <module>
y.append(int(xandy[1]))
ValueError: invalid literal for int() with base 10: '9\n93845'