Python 3 - Saving a google spreadsheet as a csv -


i trying save private google spreadsheet csv. have found thread has addressed (download spreadsheet google docs using python), answers date 2012. there solution have tried used, running errors. code using

import csv import gspread  username = "username"  //used actual username, password , doc-id in python scriptpassword = "password"  docid = "doc-id"  client = gspread.login(username, password) spreadsheet = client.open_by_key(docid) i, worksheet in enumerate(spreadsheet.worksheets()): filename = docid + '-worksheet' + str(i) + '.csv' open(filename, 'wb') f:     writer = csv.writer(f)     writer.writerows(worksheet.get_all_values()) 

this error idle throwing up

  writer.writerows(worksheet.get_all_values())   typeerror: 'str' not support buffer interface 

as must have realized, pretty new python , trying solve problem. can point out issue code using?

in python 3, open file in text mode, , set newline '' let csv writer control newlines written:

with open(filename, 'w', newline='') f:     writer = csv.writer(f)     writer.writerows(worksheet.get_all_values()) 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -