Created
January 27, 2019 16:58
-
-
Save ccerv1/87d368efab865d269fc986085ed3e429 to your computer and use it in GitHub Desktop.
Create a dataframe with the latest USDA coffee statistics
This file contains hidden or 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
| import pandas as pd | |
| import requests, zipfile, io | |
| # requests the data from the USDA url | |
| response = requests.get('https://apps.fas.usda.gov/psdonline/downloads/psd_coffee_csv.zip') | |
| # the response is a zipfile, which we unzip in memory rather than saving to the disk | |
| zf = zipfile.ZipFile(io.BytesIO(response.content)) | |
| usda = pd.read_csv(zf.open('psd_coffee.csv')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment