Package: clss
clssCommand-lineSpreadsheets.clss -s SPREADSHEET_ID -w WORKSHEET [-r RANGE] [-f FORMAT] (append | dump | upload)Small utility for interacting with Google spreadsheets, appending rows
or syncing data back and forth between local ASCII/CSV/JSON files.Usage: timesheetsThe motivating use case was keeping timesheets for projects. After
looking at several web-based solutions which were either way too heavy
or noisy (as in bells and whistles) for this use-case, I got the idea
of simply using shared spreadsheets via Google Sheets.Let's say we were keeping timesheets for projects in a Google
spreadsheet like so:DateUserProjectHoursDescriptionComment2021-03-01franksh10025.0Stared out of the window2021-03-02franksh10013.5Invested in pyramid schemes2021-03-02franksh40014.0Went outside to stare into the window2021-03-03franksh77779.0Resolved the Langlands program in one sittingMargin too short for proofConfiguringclssto target this worksheet by making a~/.config/clss/sheet.jsonor.sheet.jsonfile:{"spreadsheet_id":"1d6Jn6lgj7wRX_HF3pOqj-hm6VMC4A5CvrRnJYuCIk30","worksheet":"Upload","format":"ascii"}The same file could also be created with the commandclss -s 1d6Jn6lgj7wRX_HF3pOqj-hm6VMC4A5CvrRnJYuCIk30 -w Upload -f ascii args save. Leaving out arangeparameter (which works like a normal
spreadsheet range like "B2:F800") means the entire worksheet namedUploadwill be used.And the workflow would be something like this:$clssdump
Date|User|Project|Hours|Description|Comment2021-03-01|franksh|1002|5|Staredoutofthewindow|2021-03-02|franksh|1001|3.5|Investedinpyramidschemes|2021-03-02|franksh|1002|4|Wentoutsidetostareintothewindow|2021-03-03|franksh|7777|9|ResolvedtheLanglandsprograminonesitting|Margintooshortforproof
$clssappend`date+%Y-%m-%d`"$USER"20012.5"Wrote README and documentation"$clssdump
Date|User|Project|Hours|Description|Comment2021-03-01|franksh|1002|5|Staredoutofthewindow|2021-03-02|franksh|1001|3.5|Investedinpyramidschemes|2021-03-02|franksh|1002|4|Wentoutsidetostareintothewindow|2021-03-03|franksh|7777|9|ResolvedtheLanglandsprograminonesitting|Margintooshortforproof2021-03-14|franksh|2001|2.5|WroteREADMEanddocumentation|Alternatively the file could be kept offline in a.txt,.csv, or.jsonand then regularly synced up to the worksheet withclss upload timesheet.csv.Install and SetupRequirementsMake sure you havepython 3.7+installed with itspippackage
installer:$ pip --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)(Note:pythonandpipmight be calledpython3andpip3on
legacy-oriented distros such as Ubuntu.) If you don't havepipinstalled as a separate command, note thatpip [args...]is
equivalent to runningpython -m pip [args...]:$ python39 -m pip --version
pip 21.0.1 from /home/franksh/envs/py39/lib/python3.9/site-packages/pip (python 3.9)Install$ pip install clss(If not using a virtual environments, it's recommended to add the--userflag to install to~/.localinstead:pip install --user clss)Nowclssshould work:$ clss
Usage: clss [OPTIONS] COMMAND [ARGS]...

  Command-Line SpreadSheet utility.

  Modifies Google spreadheets from command-line via Sheets API.

Options:
  --version                      Show the version and exit.
  -v, --verbose                  Increase verbosity level. Use '-vv' to also
                                 show debug messages.
...SetupConfigureclssuse a fixed spreadsheet document and worksheet for
future invocations:$clss-sSPREADSHEET_ID-wWORKSHEET[-rRANGE][-fFORMAT]argssaveTo allow the utility to interact with your Google spreadsheets it
needs Google API credentials (which allows it to request login tokens
with certain permissions from a Google user). There's several ways of
making these credentials, but the absolute easiest way is to click the[Enable the Google Sheets API]button on theAPI quickstart
page.
(Everything else on this page is irrelevant.)Now run a command likeclss -C CREDENTIALS_FILE dumpand it should
open a browser window asking you to verify the app's login with your
Google account. (Google will complain it's unsafe and attempt to hide
the button under[Advanced]and[Go to Quickstart (unsafe)], but
there's not much to be done about that.) The login will be cached and
refreshed in the future so this step only happens once.(See alsoclss helpandclss help credentialsfor further walls of
text essentially giving the same information.)