News for hackers. Stuff that matters.
Re:Tosheets, utility to send stdin to Google sheets by notaboutdave on Friday November 17, 2017 @09:40PM (#15727495)
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'
Re:Tosheets, utility to send stdin to Google sheets by sillysaurus3 on Saturday November 18, 2017 @12:12AM (#15727856)
Can I nerd out over how unreasonably effective regexps are?

That's basically a mini JSON parser in 48 characters.

Re:Tosheets, utility to send stdin to Google sheets by gcr on Saturday November 18, 2017 @12:27AM (#15727883)
With a domain-specific tool, it's even easier though.

    curl ... | jq -r .last
Re:Tosheets, utility to send stdin to Google sheets by sillysaurus3 on Saturday November 18, 2017 @12:28AM (#15727884)
Sure. But you can't use jq to scrape arbitrary websites, for example. :)
Re:Tosheets, utility to send stdin to Google sheets by dpflan on Saturday November 18, 2017 @08:52AM (#15728922)
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. “””

Re:Tosheets, utility to send stdin to Google sheets by alexozer on Saturday November 18, 2017 @12:00PM (#15729735)
Let's not forget about this masterpiece: https://stackoverflow.com/a/1732454/864310
Re:Tosheets, utility to send stdin to Google sheets by dpflan on Saturday November 18, 2017 @12:08PM (#15729773)
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 by ams6110 on Saturday November 18, 2017 @03:16PM (#15730443)
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 by jldugger on Saturday November 18, 2017 @02:11AM (#15728103)
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 by nurettin on Saturday November 18, 2017 @03:57AM (#15728324)
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 by heptathorp on Saturday November 18, 2017 @10:00AM (#15729165)
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 by dang on Saturday November 18, 2017 @06:51PM (#15731380)
Please don't do this here.
Re:Tosheets, utility to send stdin to Google sheets by thesandlord on Saturday November 18, 2017 @12:15AM (#15727860)
I wrote something similar that will send stdin to Google Stackdriver Logging.

https://github.com/thesandlord/logpipe

Re:Tosheets, utility to send stdin to Google sheets by troydavis on Saturday November 18, 2017 @09:26AM (#15729048)
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 < stuff.csv | logger
Re:Tosheets, utility to send stdin to Google sheets by thesandlord on Saturday November 18, 2017 @11:10AM (#15729523)
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 by fiatjaf on Saturday November 18, 2017 @08:40AM (#15728896)
Amazing.

We need more utilities like this that help integrate apps and web services between themselves and the Unix environment.

"Pipes to the web" should be like this. Not bloted a UI with forms that perform premade actions with your web apps data.

Re:Tosheets, utility to send stdin to Google sheets by tardo99 on Saturday November 18, 2017 @05:24AM (#15728483)
They mean stdout, right?
Re:Tosheets, utility to send stdin to Google sheets by forkerenok on Saturday November 18, 2017 @05:57AM (#15728551)
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

Re:Tosheets, utility to send stdin to Google sheets by jwilk on Saturday November 18, 2017 @11:06AM (#15729505)
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 by thomastjeffery on Saturday November 18, 2017 @06:58PM (#15731406)
No.

From "tosheets"'s stdin to sheets.

Re:Tosheets, utility to send stdin to Google sheets by michaelangerman on Friday November 17, 2017 @09:30PM (#15727465)
very cool
Re:Tosheets, utility to send stdin to Google sheets by O_H_E on Saturday November 18, 2017 @07:28AM (#15728729)
Interestingly Nice

Your project ruins my English

Re:Tosheets, utility to send stdin to Google sheets by nine_k on Friday November 17, 2017 @09:39PM (#15727489)
Nope, it sends stdout to sheets. Getting input from sheets would be cool, too.
Re:Tosheets, utility to send stdin to Google sheets by PowerfulWizard on Friday November 17, 2017 @09:49PM (#15727531)
Consider the command:

    tosheets --spreadsheet=ABC <myfile.txt
In this example, stdin is what goes to the spreadsheet. stdout is (I assume) nothing.
Re:Tosheets, utility to send stdin to Google sheets by fluffyllemon on Friday November 17, 2017 @09:53PM (#15727545)
Re:Tosheets, utility to send stdin to Google sheets by Naac on Friday November 17, 2017 @09:43PM (#15727508)
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"
Re:Tosheets, utility to send stdin to Google sheets by reificator on Saturday November 18, 2017 @12:05AM (#15727847)
When you run this utility, it forwards stdin to Google Sheets.

Should you pipeline stdout from somewhere else to this utility, the contents of that stdout will be forwarded to Google Sheets.

It is correct to say either that you are forwarding stdin or that you are forwarding stdout. It is therefore not correct to say that it does not forward stdin, because the source code explicitly refers to stdin. That's likely the reason for the [Fight Club]s the GP is receiving.

Re:Tosheets, utility to send stdin to Google sheets by jwilk on Saturday November 18, 2017 @10:59AM (#15729458)
From the HN guidelines:

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