Live data from Hacker News

Tosheets, utility to send stdin to Google sheets

github.com

11–20 of 30 posts

Re: Tosheets, utility to send stdin to Google sheets

#11

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.

With a domain-specific tool, it's even easier though.

    curl ... | jq -r .last

Re: Tosheets, utility to send stdin to Google sheets

#12
post #11

Earlier quoted context omitted.

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

With a domain-specific tool, it's even easier though. curl ... | jq -r .last

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

Re: Tosheets, utility to send stdin to Google sheets

#13
post #11

Earlier quoted context omitted.

With a domain-specific tool, it's even easier though. curl ... | jq -r .last

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

Of course, if it's anything like HTML, the formatting will vary over time that you really want a more permissive parser like BeautifulSoup. I haven't found a cli interface, so I briefly wrote my own ages ago: https://github.com/jldugger/dotfiles/blob/master/bin/select.....

Re: Tosheets, utility to send stdin to Google sheets

#15
post #11

Earlier quoted context omitted.

With a domain-specific tool, it's even easier though. curl ... | jq -r .last

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

For cases where a website is not a tutorial for websites, regex is a suitable tool for scraping.

Re: Tosheets, utility to send stdin to Google sheets

#20
post #11

Earlier quoted context omitted.

With a domain-specific tool, it's even easier though. curl ... | jq -r .last

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. “””

Post reply on HN