I have a need to upload/insert and update a CSV file into a designated Google Spreadsheet.
Python script must take input of CSV name on filesystem (Mac), year and month for processing on the command line. The specific Google Spreadsheet ID can be stored as a parameter in the script (i.e. will remain static). Version 4 of the sheets API must be used, and the upload of data should not interfere with existing formulas in the sheet.
As per screenshot of the spreadsheet (access will be provided on successful assignment), the year and month are used to define which tab of the spreadsheet the data must be inserted/updated into.
The CSV will always represent the full month of data, so overwriting the cells is permitted (rather than having to figure out what data was stored there previously).
Example CSV is attached, as is screenshot of the current Google Spreadsheet.
Script should gracefully error out if it cannot connect/hits API limits in Google. I will also need sufficient comments in the script to enable me to add additional columns at a later date as well.
Additional context if required:
Data is being exported out of Toggl and output into the CSV, I have coded that bit in Perl (because I know the language well) the Google Spreadsheets API is the bit giving me a headache, hence why we are here. Therefore the input can be changed if required such as adding a header row, open to other options as well.
The end goal is to run the perl script daily to get a new CSV dump from Toggl, then push overwrite the existing rows in the timesheet tab for the month in question.
Authentication should be handled as per current Google API standards documented at https://developers.google.com/sheets/api/quickstart/python