generated from carpentries/workbench-template-md
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add questions/objectives/keypoints + first challenge
- Loading branch information
Showing
2 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,9 +50,9 @@ contact: '[email protected]' | |
# | ||
# Example ------------- | ||
# | ||
# episodes: | ||
# - introduction.md | ||
# - first-steps.md | ||
episodes: | ||
- introduction.md | ||
- downloading-files-programmatically.md | ||
# | ||
# learners: | ||
# - setup.md | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
title: Downloading files programmatically | ||
teaching: 0 | ||
exercises: 0 | ||
--- | ||
|
||
:::::::: questions | ||
|
||
* How can I get data when there isn't a 'download' link? | ||
* How can I work with data that is behind an API with access restrictions? | ||
|
||
:::::::: | ||
|
||
:::::::: objectives | ||
|
||
* request data from a REST API using `requests` | ||
* authenticate to a REST API using HTTP basic auth, bearer tokens, etc. | ||
* explore directories in AWS cloud buckets | ||
* download data from AWS using pandas | ||
|
||
:::::::: | ||
|
||
:::::::: challenge | ||
|
||
Make a `GET` request to `https://www.catalyst.coop` using `requests`! | ||
|
||
:::: solution | ||
|
||
```python | ||
import requests | ||
|
||
requests.get("https://www.catalyst.coop") | ||
``` | ||
|
||
:::: | ||
|
||
:::::::: | ||
|
||
:::::::: keypoints | ||
|
||
* `pandas.read_*` can read tabular data from remote servers & cloud storage as if it was on your local computer | ||
* `requests` can get data from APIs, though you'll have to do the translation from their response format into `pandas.DataFrame` yourself | ||
* To get access to access-restricted APIs, you will usually pass in an API key, as a request *header* or as a request *parameter*. Both `requests` and `pandas.read_*` have the ability to do this. | ||
|
||
:::::::: |