Skip to content

Instantly share code, notes, and snippets.

@burrussmp
Last active March 30, 2020 06:36
Show Gist options
  • Save burrussmp/7fcb0bf49c5dd8e0672afe16e733c06a to your computer and use it in GitHub Desktop.
Save burrussmp/7fcb0bf49c5dd8e0672afe16e733c06a to your computer and use it in GitHub Desktop.
Sending a csv file remotely to google drive
def sendToGoogleDrive(fileName,filePath,pathToClientSecrets="/PATH/TO/credentials.json"):
gauth = GoogleAuth()
gauth.LoadClientConfigFile(pathToClientSecrets) # <-----
drive = GoogleDrive(gauth)
folder_id = 'XXXX' // example .../folders/XXXX or ..../folders/13vovGVWKWz1KvFmBFwjxIMCT5dE-WFSx
file1 = drive.CreateFile({
'title': 'data.csv',
"mimeType": "text/csv",
'parents': [{'id': folder_id}]
}) # Create GoogleDriveFile instance with title 'Hello.txt'.
file1.SetContentFile(filePath)
file1.Upload()
print("Dataset uploaded")
print(filePath)
#os.remove(filePath)
#print("Dataset removed from local machine")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment