gpt4 book ai didi

Python can not read CSV file(Python无法读取CSV文件)

转载 作者:bug小助手 更新时间:2023-10-25 13:30:30 27 4
gpt4 key购买 nike



I am trying to read a file but the file path is having an issue.

我正在尝试读取文件,但文件路径出现问题。


Here is the line of the code:

以下是代码行:


data = pd.read_csv(C:/Users/pythonmonkey/OneDrive/Desktop/Python Projects/'GlobalLandTemperaturesByMajorCity.csv')

数据=pd.read_csv(C:/Users/pythonmonkey/OneDrive/Desktop/Python Projects/‘GlobalLandTemperaturesByMajorCity.csv’)


Here is the error:
SyntaxError: invalid syntax

以下是错误:语法错误:无效语法


Can someone please help me find out what's wrong with line?

有没有人能帮我找出LINE出了什么问题?


I tried to change the "" to "/"

我试着把“”改成“/”


I extracted the file path directly from the file properties, and I have double and triple check the spelling.

我直接从文件属性中提取了文件路径,并对拼写进行了两次和三次检查。


更多回答
优秀答案推荐

You should try to specify the quote around the whole path.

您应该尝试在整个路径周围指定引号。


file_path = "C:/Users/pythonmonkey/OneDrive/Desktop/Python Projects/GlobalLandTemperaturesByMajorCity.csv"
data = pd.read_csv(file_path)

更多回答

Tried and it says FileNotFoundError Very odd

已尝试,并显示FileNotFoundError非常奇怪

Can you copy paste the path in your explorer window and tell me if it opens?

你能在浏览器窗口中复制粘贴路径,然后告诉我它是否打开了吗?

Yeah, the file would be downloaded

是的,文件会被下载

Ahh okay I see the file is on onedrive. You have first to download it on you local pc in order to open it that way

啊,好的,我看到文件在OneDrive上了。您必须首先将其下载到本地PC上,才能以这种方式打开它

Or you can download it with python or use some library for it to fetch it

或者,您可以使用Python下载它,或者使用某个库来获取它

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com