Also change username to your google account email (because the service account is the creator only it can see the sheet unless you share it with you first). Save the client secrets json on your computer and change the path to it in the code. Sh.share(username, perm_type='user', role='writer')Īll you need to do is get a service account with google sheets and google drive api enabled (read here Authentication - gspread 3.7.0 documentation how to do it). Sh = gc.create(os.path.basename(csvpath)) Gauth.credentials = om_json_keyfile_name(credentialspath, scope) Username = in path to client secret fileĬredentialspath = '/Users/username/client_secret.json'Ĭontent = open(csvpath, 'r', encoding="utf8").read() #!/Library/Frameworks/amework/Versions/3.9/bin/python3.9įrom th import ServiceAccountCredentials I think there is room for some error handling (got some errors when opening a csv with some unsual chars).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |