I just downloaded Pandas through VS Code Python and I'm getting this error on my screen.
I've tried moving around the numbers in the CSV file. The code is finding the file of course. I'm currently using 3.10 through Windows 11.
I'm using this code to print out the CSV file:
import time
import os
import pandas
while True:
if os.path.exists("the_basics/temps_today.csv"):
data = pandas.read_csv("the_basics/temps_today.csv")
print(data.mean())
else:
print("Cannot find file. ")
time.sleep(10)
This is the CSV file:
st1 st2
23.3 22.1
24.0 23.1
22.1 20.2
19.1 16.8
This is error that I'm getting:
Traceback (most recent call last):
File "c:\Users\18607\Python_Project_1\the_basics\sketch.py", line 7, in <module>
data = pandas.read_csv("the_basics/temps_today.csv")
File "C:\Users\18607\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\util\_decorators.py", line 311, in wrapper
return func(*args, **kwargs)
File "C:\Users\18607\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\parsers\readers.py", line 586, in read_csv
return _read(filepath_or_buffer, kwds)
File "C:\Users\18607\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\parsers\readers.py", line 482, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File "C:\Users\18607\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\parsers\readers.py", line 811, in __init__
self._engine = self._make_engine(self.engine)
File "C:\Users\18607\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\parsers\readers.py", line 1040, in _make_engine
return mapping[engine](self.f, **self.options) # type: ignore[call-arg]
File "C:\Users\18607\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\parsers\c_parser_wrapper.py", line 69, in __init__
self._reader = parsers.TextReader(self.handles.handle, **kwds)
File "pandas\_libs\parsers.pyx", line 549, in pandas._libs.parsers.TextReader.__cinit__
pandas.errors.EmptyDataError: No columns to parse from file'