Caledonian26
Caledonian26

Reputation: 809

File path for excel file

I have the file EnergyIndicators.xls, which I want to read into python so I can manipulate it.

How can I obtain the file path so I can read the file in using the:

pd.read_excel() function?

Upvotes: 1

Views: 3788

Answers (3)

Kastakin
Kastakin

Reputation: 129

You should call the xls file with his absolute path or relative path to the script trying to access it as such:

df = pd.read_excel('path/to/your/file.xls')

Depending on your OS you could get the path to the file in different ways:

For Linux in the terminal once inside the folder containing your file:

pwd #this will get the current working folder

In Windows you can simply navigate to the location where your file is located and click in the navigato bar to get the path to the directory.

Upvotes: 0

jmish
jmish

Reputation: 3

Firstly you need to know the path to the file in your file system.

Then you just simply pass the path to xls file to read_excel function.

  • pd.read_excel('path/to/direct/EnergyIndicators.xls')

Upvotes: 0

Lokendra Choudhary
Lokendra Choudhary

Reputation: 479

Get excel file location from the file info and use this reference for syntax. https://pandas.pydata.org/pandas-docs/version/0.23.4/generated/pandas.read_excel.html Pretty straightforward.

Upvotes: 1

Related Questions