简体   繁体   English

excel 文件的文件路径

[英]File path for excel file

I have the file EnergyIndicators.xls, which I want to read into python so I can manipulate it.我有文件 EnergyIndicators.xls,我想将其读入 python 以便我可以对其进行操作。

How can I obtain the file path so I can read the file in using the:如何获取文件路径,以便可以使用以下方式读取文件:

pd.read_excel() function? pd.read_excel() function?

Get excel file location from the file info and use this reference for syntax.从文件信息中获取 excel 文件位置并使用此参考作为语法。 https://pandas.pydata.org/pandas-docs/version/0.23.4/generated/pandas.read_excel.html Pretty straightforward. https://pandas.pydata.org/pandas-docs/version/0.23.4/generated/pandas.read_excel.html 非常简单。

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.然后,您只需将xls文件的路径传递给read_excel function。

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

You should call the xls file with his absolute path or relative path to the script trying to access it as such:您应该使用他的绝对路径或脚本的相对路径来调用 xls 文件,以尝试访问它:

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:对于 Linux 在包含您的文件的文件夹中的终端中:

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.在 Windows 中,您可以简单地导航到文件所在的位置,然后单击导航栏以获取目录的路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM