0

I want to read data from an excel file. Data are in one column. They are 2d array of points. For this, I write the following code:

import pandas as pd

df = pd.read_excel ("G:\programfile\anaconda3\envs\TESTJT\test.xlsx")

print (df)
...
VALUEX= df[::2]
VALUEY= df[1::2]

plot(VALUEX, VALUEY, 'bo')  # plot x and y using blue circle markers
...

When I run code in the activated file for Conda, it shows a "Traceback" error. It seems the error is about pandas.

Can someone explain why this error appears?


This is what I see when I run my code from anaconda command prompt:

Traceback (most recent call last):
  File "G:\programfile\anaconda3\envs\TESTJT\test.py", line 3, in <module>
    df = pd.read_excel ("G:\programfile\anaconda3\envs\TESTJT\test.xlsx")
  File "G:\programfile\anaconda3\lib\site-packages\pandas\util\_decorators.py",
line 296, in wrapper
    return func(*args, **kwargs)
  File "G:\programfile\anaconda3\lib\site-packages\pandas\io\excel\_base.py", li
ne 304, in read_excel
    io = ExcelFile(io, engine=engine)
  File "G:\programfile\anaconda3\lib\site-packages\pandas\io\excel\_base.py", li
ne 867, in __init__
    self._reader = self._engines[engine](self._io)
  File "G:\programfile\anaconda3\lib\site-packages\pandas\io\excel\_xlrd.py", li
ne 22, in __init__
    super().__init__(filepath_or_buffer)
  File "G:\programfile\anaconda3\lib\site-packages\pandas\io\excel\_base.py", li
ne 353, in __init__
    self.book = self.load_workbook(filepath_or_buffer)
  File "G:\programfile\anaconda3\lib\site-packages\pandas\io\excel\_xlrd.py", li
ne 37, in load_workbook
    return open_workbook(filepath_or_buffer)
  File "G:\programfile\anaconda3\lib\site-packages\xlrd\__init__.py", line 111,
in open_workbook
    with open(filename, "rb") as f:
OSError: [Errno 22] Invalid argument: 'G:\\programfile\x07naconda3\\envs\\TESTJT
\test.xlsx'
NULL
  • 5
  • 1
  • 4

1 Answers1

0

Well, its prolly a bad file path or difficulty parsing the path. Stick an r in front of your file path string and remember to search your error message.

df = pd.read_excel (r"G:\programfile\anaconda3\envs\TESTJT\test.xlsx")
born_naked
  • 748
  • 9
  • 19