"CSV文件不存在"带有嵌入式引号的文件名 [英] "CSV file does not exist" for a filename with embedded quotes

查看:153
本文介绍了"CSV文件不存在"带有嵌入式引号的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在学习Pandas进行数据分析,并且在Atom编辑器中读取csv文件时遇到一些问题.

I am currently learning Pandas for data analysis and having some issues reading a csv file in Atom editor.

当我运行以下代码时:

import pandas as pd 

df = pd.read_csv("FBI-CRIME11.csv")

print(df.head())

我收到一条错误消息,结尾为

I get an error message, which ends with

OSError:文件b'FBI-CRIME11.csv'不存在

OSError: File b'FBI-CRIME11.csv' does not exist

这是文件的目录:/Users/alekseinabatov/Documents/Python/"FBI-CRIME11.csv.

Here is the directory to the file: /Users/alekseinabatov/Documents/Python/"FBI-CRIME11.csv".

当我尝试以这种方式运行它时:

When i try to run it this way:

df = pd.read_csv(Users/alekseinabatov/Documents/Python/"FBI-CRIME11.csv")

我遇到另一个错误:

NameError:名称'Users'未定义

NameError: name 'Users' is not defined

我也已将该目录放入编辑器设置中的"Project Home"字段中,尽管我不确定它是否有任何作用.

I have also put this directory into the "Project Home" field in the editor settings, though I am not quite sure if it makes any difference.

我敢打赌,有一种简单的方法可以使其正常工作.我将衷心感谢您的帮助!

I bet there is an easy way to get it to work. I would really appreciate your help!

推荐答案

您尝试过吗?

df = pd.read_csv("Users/alekseinabatov/Documents/Python/FBI-CRIME11.csv")

或者也许

df = pd.read_csv('Users/alekseinabatov/Documents/Python/"FBI-CRIME11.csv"')

(如果文件名带有引号)

(If the file name has quotes)

这篇关于"CSV文件不存在"带有嵌入式引号的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆