5 ms·
Tosheets, utility to send stdin to Google sheets
- michaelangerman 9y agovery cool
- nine_k 9y agoNope, it sends stdout to sheets. Getting input from sheets would be cool, too.
- Naac 9y agoIt 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"
- reificator 9y agoWhen 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.
- jwilk 9y agoFrom the HN guidelines: Please don't comment about the voting on comments. It never does any good, and it makes boring reading.
- PowerfulWizard 9y agoConsider the command: tosheets --spreadsheet=ABC <myfile.txt In this example, stdin is what goes to the spreadsheet. stdout is (I assume) nothing.
- fluffyllemon 9y agotosheets definitely reads from stdin: https://github.com/kren1/tosheets/blob/8a853d2ebb722c474f5bbe15531d16e7ef3f1528/tosheets/tosheets.py#L113 https://github.com/kren1/tosheets/blob/8a853d2ebb722c474f5bb... :)
- notaboutdave 9y agoThis 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'
- sillysaurus3 9y agoCan I nerd out over how unreasonably effective regexps are? That's basically a mini JSON parser in 48 characters.
- gcr 9y agoWith a domain-specific tool, it's even easier though. curl ... | jq -r .last
- sillysaurus3 9y agoSure. But you can't use jq to scrape arbitrary websites, for example. :)
- jldugger 9y agoOf 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.py https://github.com/jldugger/dotfiles/blob/master/bin/select.....
- nurettin 9y agoFor cases where a website is not a tutorial for websites, regex is a suitable tool for scraping.
- dpflan 9y agoJeff Atwood has an entertaining post about parsing HTML with regular expressions: https://blog.codinghorror.com/parsing-html-the-cthulhu-way/ 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. “””
- thesandlord 9y agoI wrote something similar that will send stdin to Google Stackdriver Logging. https://github.com/thesandlord/logpipe https://github.com/thesandlord/logpipe
- troydavis 9y agoIn 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/ 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
- thesandlord 9y agoYeah 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 https://youtu.be/c5ufcpTGIJM
- deleted 9y ago[deleted]
- tardo99 9y agoThey mean stdout, right?
- forkerenok 9y agoDepends on from where you look :) It is stdout for the previous process in the pipeline and stdin for the tosheets itself. EDIT: Tosheets -> tosheets
- jwilk 9y agotosheets 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.
- thomastjeffery 9y agoNo. From "tosheets"'s stdin to sheets.
- O_H_E 9y agoInterestingly Nice Your project ruins my English
- fiatjaf 9y agoAmazing. 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.