Live data from Hacker News

Tosheets, utility to send stdin to Google sheets

github.com

21–30 of 30 posts

Re: Tosheets, utility to send stdin to Google sheets

#21

I wrote something similar that will send stdin to Google Stackdriver Logging. https://github.com/thesandlord/logpipe

In the same vein, pipe anything to `logger` to send it to the local syslogd (and if configured, to remote destinations).

For example, this uses datamash (https://www.gnu.org/software/datamash/) to sum column 2 of a CSV ("-t,"), then log the output:

    datamash -t, sum 2 

Re: Tosheets, utility to send stdin to Google sheets

#22

This is pretty great. It looks like it automatically writes to the next logical empty cell. curl https://www.bitstamp.net/api/v2/ticker/btcusd \ | grep 'last": *"\d*\.\d*' -o | grep '\d*\.\d*' -o \ | tosheets -c A1 --spreadsheet=foo ^ That will append the last BTC price to column A of sheet 'foo'

Can I nerd out over how unreasonably effective regexps are? That's basically a mini JSON parser in 48 characters.

Do NOT use r̔ͩegͩ̾ͪͥͪeͮ͊ͨ̓xͫ͆͆̓ ͤt͊͗o̒̾͋ͬ̾̚ ͆̌͌̄p͠a͟r̐̎͆̽̄ͭ́se̒ͥ ͕̪̻̭̭̺̳ͣͬͪͫͪj̞̲ͤ̚s̡̳̟̤̳̖̤͒̋ͣ͊ͤ͗̿oͬ̀͆n̮̳͚̝̩͙͔̈͋ ̮͕̩̼̔̾̈̄̋ͦ́́̚ͅĤ̷̝̯̝ͯ̈́ͣ̔ͪ̊ͬ͜͡Eͬͧ҉̜̰̲̩̰̝̠̥ ̶̯̯͚̗̪̭̘ͨͩͭ̎ͧͮCͪ҉̖͍͔͚͚̯͕Ơ̰̻̂̅̋̇̓̅͌M̸̭̱̭̥͆̽ͨͦÊ̸̴̢̪͚̮̲̜̙̍ͤ͋̾ͦS̛̗̟͙͍̹͈̳ͣ͑̏̓ͤͦ̽

Re: Tosheets, utility to send stdin to Google sheets

#23
post #5
post #3

Nope, it sends stdout to sheets. Getting input from sheets would be cool, too.

It looks to me like you're being downvoted, but what you're saying looks correct to me. $PROGRAM sends to stdout what google sheets reads from "stdin"

From the HN guidelines:

Please don't comment about the voting on comments. It never does any good, and it makes boring reading.

Re: Tosheets, utility to send stdin to Google sheets

#24
post #16

They mean stdout, right?

Depends on from where you look :) It is stdout for the previous process in the pipeline and stdin for the tosheets itself. EDIT: Tosheets -> tosheets

tosheets just reads stuff from stdin. It doesn't care if it's attached to a pipe or not. It might be that there's no "previous process" at all.

Re: Tosheets, utility to send stdin to Google sheets

#25

I wrote something similar that will send stdin to Google Stackdriver Logging. https://github.com/thesandlord/logpipe

In the same vein, pipe anything to `logger` to send it to the local syslogd (and if configured, to remote destinations). For example, this uses datamash ( https://www.gnu.org/software/datamash/ ) to sum column 2 of a CSV ("-t,"), then log the output: datamash -t, sum 2

Yeah logger or fluentd are definitely better long term solutions. I wanted something that was no frills and minimal config for ad-hoc situations. Other's on my team found it useful so I open sourced it.

Bonus: In depth code review for this package: https://youtu.be/c5ufcpTGIJM

Re: Tosheets, utility to send stdin to Google sheets

#26
post #20

Earlier quoted context omitted.

Sure. But you can't use jq to scrape arbitrary websites, for example. :)

Jeff Atwood has an entertaining post about parsing HTML with regular expressions: https://blog.codinghorror.com/parsing-html-the-cthulhu-way/ “”” That's right, if you attempt to parse HTML with regular expressions, you're succumbing to the temptations of the dark god Cthulhu's … er … code. “””

Let's not forget about this masterpiece: https://stackoverflow.com/a/1732454/864310

Re: Tosheets, utility to send stdin to Google sheets

#27
post #20

Earlier quoted context omitted.

Jeff Atwood has an entertaining post about parsing HTML with regular expressions: https://blog.codinghorror.com/parsing-html-the-cthulhu-way/ “”” That's right, if you attempt to parse HTML with regular expressions, you're succumbing to the temptations of the dark god Cthulhu's … er … code. “””

Let's not forget about this masterpiece: https://stackoverflow.com/a/1732454/864310

Indeed, its quality cannot be ignored and must be shared; it’s referenced in the Atwood post.

Re: Tosheets, utility to send stdin to Google sheets

#28
post #20

Earlier quoted context omitted.

Sure. But you can't use jq to scrape arbitrary websites, for example. :)

Jeff Atwood has an entertaining post about parsing HTML with regular expressions: https://blog.codinghorror.com/parsing-html-the-cthulhu-way/ “”” That's right, if you attempt to parse HTML with regular expressions, you're succumbing to the temptations of the dark god Cthulhu's … er … code. “””

Parsing and scraping are different things though. You don't need to parse a web page to extract specific things from it.

Re: Tosheets, utility to send stdin to Google sheets

#29

Earlier quoted context omitted.

Can I nerd out over how unreasonably effective regexps are? That's basically a mini JSON parser in 48 characters.

Do NOT use r̔ͩegͩ̾ͪͥͪeͮ͊ͨ̓xͫ͆͆̓ ͤt͊͗o̒̾͋ͬ̾̚ ͆̌͌̄p͠a͟r̐̎͆̽̄ͭ́se̒ͥ ͕̪̻̭̭̺̳ͣͬͪͫͪj̞̲ͤ̚s̡̳̟̤̳̖̤͒̋ͣ͊ͤ͗̿oͬ̀͆n̮̳͚̝̩͙͔̈͋ ̮͕̩̼̔̾̈̄̋ͦ́́̚ͅĤ̷̝̯̝ͯ̈́ͣ̔ͪ̊ͬ͜͡Eͬͧ҉̜̰̲̩̰̝̠̥ ̶̯̯͚̗̪̭̘ͨͩͭ̎ͧͮCͪ҉̖͍͔͚͚̯͕Ơ̰̻̂̅̋̇̓̅͌M̸̭̱̭̥͆̽ͨͦÊ̸̴̢̪͚̮̲̜̙̍ͤ͋̾ͦS̛̗̟͙͍̹͈̳ͣ͑̏̓ͤͦ̽

Please don't do this here.
Post reply on HN