I'm trying to build an app off the idea of SeaofBTCapp (Sentdex), and Python/Tkinter does not find my "sampleData.csv" file despite being sure I have the right directory. (I've tried .csv and .txt extensions to no avail.) I hope this MWE is not too minimal, obviously I import tkinter and other matplotlib modules, and I from my understanding, the open() function is native to python.
Function:
import matplotlib.animation as animation
def animate(i):
pullData = open('sampleData.csv', "r").read()
dataList = pullData.split('\n')
xList =[]
yList = []
for eachLine in dataList:
if len(eachLine)>1:
x, y = eachLine.split(',')
xList.append(int(x))
yList.append(int(y))
a.clear()
a.plot(xList, yList )
Traceback:
File "/Users/nrsmoll/PycharmProjects/SeaofStats/main.py", line 27, in animate
pullData = open('sampleData.csv', "r").read()
FileNotFoundError: [Errno 2] No such file or directory: 'sampleData.csv'
File system checks:
print(os.getcwd())
/Users/nrsmoll/PycharmProjects/SeaofStats
print(os.listdir())
['.DS_Store', 'main.py', 'sampleData.csv', '.idea']
print(os.listdir())
['.DS_Store', 'sampleData.csv', 'main.py', '.idea']
print(os.path.exists(r"sampleData.csv"))
True