pydrive

Upload and convert XLSX to Google Sheets with PyDrive

≯℡__Kan透↙ 提交于 2020-07-21 07:41:32
问题 I am trying to upload a .xlsx file to google drive. I am able to upload it. But when we try to open the same file in Drive, it has to be opened with Google Sheets. Thus, it creates a new file with same name and consumes Drive space. I suppose I need to change the MimeType while uploading. What I have tried is : file = drive.CreateFile({"parents": [{"kind": "drive#fileLink", "id": FolderID}] ,'title': fileName ,'mimeType':'application/vnd.ms-excel'}) file.SetContentFile('12dec2018.xlsx') file

Upload File to Google-drive Teamdrive folder with PyDrive

北城余情 提交于 2020-06-26 05:21:28
问题 I have been successfully uploading files to a google-drive-folder with PyDrive. But, when it comes to uploading files to a folder in a google-drive-teamdrive-folder which is shared with me, the following code is not working. from pydrive.auth import GoogleAuth from pydrive.drive import GoogleDrive gauth = GoogleAuth() gauth.LocalWebserverAuth() drive = GoogleDrive(gauth) location_to_save = "D:\images" mImageLoc = location_to_save + "\\abcd.jpg" #[...Code to fetch and save the file as abcd.jpg

Google docs formatting, converting texts into sheets

こ雲淡風輕ζ 提交于 2020-02-04 01:28:14
问题 I've had success in sending a google docs file into a google sheets and the spreadsheet managed to fill itself in correctly (it formats the text into a table, very neat) Below is an example of how I'm formatting my text: ID, NAME, MOBILE, CITY, COUNTRY, BIRTHDAY, 3, NameGoesHere1, 21 98658 5548, abcity, countryNameHere, 1998-05-02, 6, SomeoneElse Joined Here, 21 98535 1218, whereland, Far far away, 1989-11-15, 5, AnotherCustomer, 21 85482 5245, somecity, Somewhereland, 1999-08-04, ID, PRICE,

Google pydrive uploading a file to specific folder

…衆ロ難τιáo~ 提交于 2020-02-02 16:03:10
问题 I am trying to upload a file to my Google drive, the code below works. How can I specify to which folder to upload to i.e drive---shared with me--csvFolder from pydrive.auth import GoogleAuth from pydrive.drive import GoogleDrive gauth = GoogleAuth() gauth.LocalWebserverAuth() drive = GoogleDrive(gauth) file2 = drive.CreateFile() file2.SetContentFile('new_test.csv') file2.Upload() 回答1: You want to upload a file to the specific folder in your Google Drive using pydrive. If my understanding is

Google pydrive uploading a file to specific folder

戏子无情 提交于 2020-02-02 16:01:57
问题 I am trying to upload a file to my Google drive, the code below works. How can I specify to which folder to upload to i.e drive---shared with me--csvFolder from pydrive.auth import GoogleAuth from pydrive.drive import GoogleDrive gauth = GoogleAuth() gauth.LocalWebserverAuth() drive = GoogleDrive(gauth) file2 = drive.CreateFile() file2.SetContentFile('new_test.csv') file2.Upload() 回答1: You want to upload a file to the specific folder in your Google Drive using pydrive. If my understanding is

Google pydrive uploading a file to specific folder

╄→尐↘猪︶ㄣ 提交于 2020-02-02 16:01:07
问题 I am trying to upload a file to my Google drive, the code below works. How can I specify to which folder to upload to i.e drive---shared with me--csvFolder from pydrive.auth import GoogleAuth from pydrive.drive import GoogleDrive gauth = GoogleAuth() gauth.LocalWebserverAuth() drive = GoogleDrive(gauth) file2 = drive.CreateFile() file2.SetContentFile('new_test.csv') file2.Upload() 回答1: You want to upload a file to the specific folder in your Google Drive using pydrive. If my understanding is

HttpError 403 (forbidden) when accessing Google Drive using PyDrive

送分小仙女□ 提交于 2020-01-07 04:35:22
问题 I try to perform some operations on my Google Drive using PyDrive (and service account). This account has the right scope set in admin.google.com and in Dev's Console I've turned on both Drive API and Drive SDK. Here's the code snippet: credentials = SignedJwtAssertionCredentials( service_account_name, #...@developer.gserviceaccount.com key, # from file scope, # https://www.googleapis.com/auth/drive sub='...' # user ) gauth = GoogleAuth() gauth.credentials = credentials gauth.Authorize()

Load xlsx file from drive in colaboratory

三世轮回 提交于 2020-01-03 19:03:12
问题 How can I import MS-excel(.xlsx) file from google drive into colaboratory? excel_file = drive.CreateFile({'id':'some id'}) does work( drive is a pydrive.drive.GoogleDrive object). But, print excel_file.FetchContent() returns None. And excel_file.content() throws: TypeErrorTraceback (most recent call last) in () ----> 1 excel_file.content() TypeError: '_io.BytesIO' object is not callable My intent is (given some valid file 'id') to import it as an io object, which could be read by pandas read

Pydrive google drive automate authentication

℡╲_俬逩灬. 提交于 2019-12-30 04:33:09
问题 I have the following piece of code: from pydrive.auth import GoogleAuth gauth = GoogleAuth() gauth.DEFAULT_SETTINGS = {'save_credentials': True,'client_config_backend': 'settings', 'oauth_scope': ['https://www.googleapis.com/auth/drive'], 'get_refresh_token': True, 'save_credentials_file':"credential_log.txt", 'save_credentials_backend': 'file'} gauth.client_config = {'client_id': '499039293801-krogpnentl6qk035vt4hcd36nefiautt.apps.googleusercontent.com', 'client_secret':

PyDrive guath.Refresh() and Refresh Token Issues

放肆的年华 提交于 2019-12-22 08:15:42
问题 Like others, I'm trying to get the Google refresh token to work in order to run scheduled tasks that copy and rename files. When I first manually authenticate within a terminal, my url ends in &access_type=offline. However, when I go in and try to manually use gauth.Refresh() in ipython, it fails with the same error as when my credentials file expires: pydrive.auth.RefreshError: No refresh_token found.Please set access_type of OAuth to offline. How do I actually set access_type to offline?