This script helps the user to upload a local csv file to google drive and share it with the user specified in the command.
The script also helps to retrieve the spreadsheet form the drive and store it locally in json format.
pip install -r requirements.txt
-
a. Go to Google Developer's Console.
b. Go to 'Library' from the left navigation panel.
c. In the search bar type 'Google Sheets API'.
d. Enable the API if not enabled or click on the manage button.
e. Similarly enable the 'Google Drive API'.
f. On the API page, goto 'Credentials' from the Navigation Panel.
g. Click on 'Create Credentials', select the service account option and name the service account.
h. Click on 'Add key' and 'Create New'.
i. File download will begin, rename this file as 'credentials.json' and place in the same folder as the scripts.
-
- Share a spreadsheet
python create_sheet.py -mail <mail_id> -csv <csv_file_name> -s <spreadsheet_name>- Retrieve the spreadsheet and store locally in json format
python get_sheet.py -j <json_file_name> -s <spreadsheet_name>
-
Creating a google spreadsheet and sharing it with the receiver.
python create_sheet.py -mail <receiver-mail_id> -csv sample.csv -s my_sample_spreadsheetThe receiver will receive a mail like this.
-
Retrieving a created spreadhsheet.
python get_sheet.py -j sample.json -s my_sample_spreadsheetCheck the sample.json for observing the output file generated.
-
Since this is a free access version for the Google Spreadsheet API, keep the size of the csv file low.
-
If you get an error such as 'resource limit exhausted', simply create a new key as mention in the step 1.h in the 'How to run the script section'. and replace your old credentials.json file with this new one.
Priya Mane