【问题标题】:Using Git clone in Google Colab and using a csv file在 Google Colab 中使用 Git 克隆并使用 csv 文件
【发布时间】:2018-06-12 13:44:50
【问题描述】:

我在 Google Colab 上使用一个 github 项目。我使用 !git clone 来克隆存储库。但后来我无法使用 pd.read_csv 读取 csv 文件。我究竟做错了什么?谢谢。

【问题讨论】:

  • 你能提供更多细节吗?您使用的具体命令是什么,错误信息是什么?

标签: google-colaboratory


【解决方案1】:

您是否在调用pd.read_csv 之前添加了 git 存储库目录? !git clone 将克隆 repo,但不会更改当前目录。您需要使用%cd 来更改目录。

因此,例如,如果您克隆 !git clone foo.git,其中包含一个名为 csv 的文件,您需要执行以下操作:

!git clone foo.git
%cd foo
pd.read_csv('csv')

【讨论】:

  • 谢谢。我使用的是 !cd 而不是 %cd。
【解决方案2】:

你可以这样试试

%cd '/content/drive/My Drive/' #point to destination directory
!git clone 'https://github.com/Recommenders' #copying from github into the destination directory

【讨论】:

    猜你喜欢
    • 2020-08-10
    • 2021-07-19
    • 1970-01-01
    • 1970-01-01
    • 2020-03-23
    • 2019-08-03
    • 2012-10-08
    • 1970-01-01
    相关资源
    最近更新 更多