Guest User

Create New Google Spreadsheet in Python

a guest
May 24th, 2013
709
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. import gspread
  2. import gdata.docs.client
  3.  
  4. password = 'password'
  5. gc = gspread.login(email, password)
  6.  
  7. filename = 'My Spreadsheet Name'
  8.  
  9. #Tries to Open Spreadsheet. If doesn't exist, creates new
  10. try:
  11.         spr = gc.open(filename)
  12. except:
  13.         gd_client = gdata.docs.client.DocsClient()
  14.         source = 'Monthly Spreadsheet'
  15.         gd_client.ClientLogin(email, password, source)
  16.         document = gdata.docs.data.Resource(type='spreadsheet', title=filename)
  17.         document = gd_client.CreateResource(document)
  18.         print 'Created Spreadsheet: '+filename
  19.         spr = gc.open(filename)
  20.         pass
Add Comment
Please, Sign In to add comment