Created
April 14, 2013 18:40
-
-
Save hrpunio/5383737 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/python | |
# Wysłanie 4 argumentów wywołania programu do arkusza na Google docs | |
# | |
import re | |
import sys | |
import time | |
import datetime | |
import gspread | |
# =========================================================================== | |
# Google Account Details | |
# =========================================================================== | |
# Account details for google docs | |
email = '???????????????????' | |
password = '????????????' | |
spreadsheet = '?????????????' | |
# =========================================================================== | |
# Example Code | |
# =========================================================================== | |
# Login with your Google account | |
try: | |
gc = gspread.login(email, password) | |
except: | |
print "Unable to log in. Check your email address/password" | |
sys.exit() | |
# Open a worksheet from your spreadsheet using the filename | |
try: | |
worksheet = gc.open(spreadsheet).sheet1 | |
# Alternatively, open a spreadsheet using the spreadsheet's key | |
# worksheet = gc.open_by_key('0BmgG6nO_6dprdS1MN3d3MkdPa142WFRrdnRRUWl1UFE') | |
except: | |
print "Unable to open the spreadsheet. Check your filename: %s" % spreadsheet | |
sys.exit() | |
a1 = float(sys.argv[1]) | |
a2 = float(sys.argv[2]) | |
a3 = float(sys.argv[3]) | |
a4 = float(sys.argv[4]) | |
# Append the data in the spreadsheet, including a timestamp | |
try: | |
values = [datetime.datetime.now(), a1, a2, a3, a4 ] | |
worksheet.append_row(values) | |
except: | |
print "Unable to append data. Check your connection?" | |
sys.exit() | |
print "Wrote a row to %s" % spreadsheet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment