forked from peters-josh/spending-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsheets.py
More file actions
executable file
·21 lines (18 loc) · 791 Bytes
/
sheets.py
File metadata and controls
executable file
·21 lines (18 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import datetime
from pytz import timezone
import gspread
from oauth2client.service_account import ServiceAccountCredentials
class Sheets:
scope = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive']
creds = ServiceAccountCredentials.from_json_keyfile_name('credentials.json', scope)
client = gspread.authorize(creds)
def add_expense(self, amount, description, category, method):
sheet = self.client.open('Budget').sheet1
row = [str(datetime.date.today()),
str(datetime.datetime.now(timezone('US/Eastern')).strftime('%H:%M:%S')),
amount,
description,
category,
method]
sheet.append_row(row, value_input_option='USER_ENTERED')