Roz
Roz

Reputation: 325

Getting a file path from GitHub

I have the code below in my Google colab, and it is giving me the error message:

FileNotFoundError: [Errno 2] No such file or directory:

Code:

!pip install arff    
import arff
uploaded = arff.load(open('https://github.com/userName/repoName/blob/combination_of_nums_and_letters/file_name.arff'))

I got the file path by clicking on "Copy permalink" in GitHub.

Is this an issue with the path I got? or with my code? And if the path is wrong how can I get the correct path for this code to work?

Upvotes: 2

Views: 1485

Answers (1)

Braeden Lisowski
Braeden Lisowski

Reputation: 87

  1. Python file open only looks locally. To open a file from the internet you will need to download it using a request.
  2. The link needs to be the "raw" version (put raw.githubusercontent instead of github.com) and remove the "/blob/" portion of it.

This question should help you: How to download and write a file from Github using Requests

Upvotes: 1

Related Questions