[SOLVED] What is the best way to retrieve a single folder from a github repository in a python script?

Issue

I need to download a single folder from a github repository in a Python 3 script.

  • Listing all raw file URLs to download is tedious and eventual new files would need to be added manually
  • Downloading the whole repository as zip takes rather long; there are lots of unneeded files. [This how I do at the moment]

I have read about web services that do what I would need, such as downgit.github.io, but the problem is that generating the relevant URL and fetching it via urllib.request.urlretrive() downloads the website rather than the actual file.

What can I do? Is there a web service that provides raw file links that I can download as described above?

Solution

I just found a solution: The ffspec library may be used to download a single folder from a GitHub repository using Python. See https://sebastianwallkoetter.wordpress.com/2022/01/30/copy-github-folders-using-python/

Answered By – mara004

Answer Checked By – Timothy Miller (BugsFixing Admin)

Leave a Reply

Your email address will not be published.