-
Library Imports:
The script begins by importing necessary libraries, including those from the Google API for authentication and file operations. -
Path Definition: It defines two paths: path_JSON and path_file, representing the paths to the JSON key (for Google Drive API authentication) and the file to be uploaded, respectively.
-
Google Drive API Setup: The script sets up the Google Drive API by using the provided JSON key (path_JSON) to obtain credentials for authentication.
-
Folder Creation on Google Drive: A folder named 'Daily_Uploads' is created on Google Drive using the Drive API. The folder ID is retrieved for future reference.
-
Sharing Folder with a Google Account: The script shares the created folder with a specified Google account using the account's email address. The specified account is given 'writer' permissions.
-
Uploading Excel File to Google Drive: An Excel file is uploaded to the created folder on Google Drive. The file's name includes 'Daily_Upload_' followed by the current date. The uploaded file ID is printed if the upload is successful.
-
Error Handling: The script includes exception handling to print any encountered errors during execution.
-
Note:
- Before running the script, you need to fill in the actual paths for path_JSON and path_file.
- Ensure that the specified Google account email (yourEmailOfGoogleAccount) is updated with the correct email address. This script automates the process of creating a folder, sharing it with a designated Google account, and uploading a file to Google Drive.