Iterate through rows of Google Spreadsheet as if it were a Python CSV DictReader or DictWriter.
See example.py for a full working example.
reader = SheetReader(
workbook_id = 'workbook_id_123',
sheet_name = 'WingPrices',
header_range=('A1', 'C1'),
data_range = ('A2','C10')
)
for row in reader:
# Read row values
num_wings = row['Chicken Wings']
price = row['Price']
# Write a value
row['Price per Wing'] = float(price) / int(num_wings)
Google's Spreadsheet API uses OAuth. To easily create a Google OAuth App
- Head to Google's Quick Start and click "Enable the Google Sheets API". For OAuth Client type, select "Web Server".
- Save
credentials.json
to your working directory - When you run a SheetReader instance, Google should open a browser to ask you to authenticate and authorize.
- Run spreadsheet values against API: Our warehouse team had a spreadsheet of shipment tracking numbers. We used SheetReader to read the tracking numbers, hit the tracking API, and update the spreadsheet with delivery date.
- Lookup spreadsheet values in database: Our marketing team had a list of customer emails who went through a marketing campaign around a new feature. We used SheetReader to compare those emails to our production database to show which users used the new feature. todo: Add postgres example