Skip to content

Instantly share code, notes, and snippets.

@ccerv1
Created January 27, 2019 16:58
Show Gist options
  • Select an option

  • Save ccerv1/87d368efab865d269fc986085ed3e429 to your computer and use it in GitHub Desktop.

Select an option

Save ccerv1/87d368efab865d269fc986085ed3e429 to your computer and use it in GitHub Desktop.
Create a dataframe with the latest USDA coffee statistics
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