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です.

コメントを残す

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

Your post must include a link to this post.

How does this work?
Write a response on your own website and include a link to this post. Then submit your response’s URL here. Your response may appear here after moderation. To update or remove it, edit or delete your original post and submit the same URL again. Learn more about Webmentions.