The actual Python code

Extracts from Google Spreadsheet