STDOUTからパイプで繋いでGoogle スプレッドシートに記録出来るtosheetsを試す

shellのSTDOUTからパイプで繋いでGoogle スプレッドシートに記録出来るtosheets 🏛️というものを見かけたのでちょっと試してみました.

導入はpipで入ります.

pip install tosheets

初回実行時には認証が走ってブラウザで許可すれば使えるようになります.

20171216_19:12:40-24220 🏛️

以下の1つ目は新規にスプレッドシートをtosheet-testという名前でスプレッドシートを作りつつunix timeとcpuの温度を投げています.
2つ目,3つ目は1つ目で作ったスプレッドシートにunix timeとcpuの温度を投げています.

$ echo -n `date +%s`,`acpi -t|awk '{print $4}'|tr -s '\n' ','`|tosheets -c a1 --new-sheet='tosheet-test' -d ','
1dEv7l3FkxEM-NKlmPTdtfKq4aaemtdyHc1mlbAUOq3s
$ echo -n `date +%s`,`acpi -t|awk '{print $4}'|tr -s '\n' ','`|tosheets -c a1 --spreadsheet=1dEv7l3FkxEM-NKlmPTdtfKq4aaemtdyHc1mlbAUOq3s -d ','
$ echo -n `date +%s`,`acpi -t|awk '{print $4}'|tr -s '\n' ','`|tosheets -c a1 --spreadsheet=1dEv7l3FkxEM-NKlmPTdtfKq4aaemtdyHc1mlbAUOq3s -d ','

ちなみにこういう感じの出力が,

$ echo -n `date +%s`,`acpi -t|awk '{print $4}'|tr -s '\n' ','`
1513421821,48.0,47.0,

スプレッドシートを見るとこういうふうに記録されています.

20171216_20:12:07-28689 🏛️

既存のスプレッドシートを使う場合はそのシートのURLからスプレッドシートIDを調べて spreadsheet optionで指定します.以下の例では 1y4qtUWqh6gSCUnEWkTcJX7y1k_1U0ph5ubdrxyUTXa4 がそれです.

https://docs.google.com/spreadsheets/d/1y4qtUWqh6gSCUnEWkTcJX7y1k_1U0ph5ubdrxyUTXa4/edit

お手軽に使えていいですね.Raspberry Pi等のSBCなんかからセンサの値を投げるとかのM2M的な使い方にも良さそうです.
Python3製でMIT Licenseです.

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)