squib icon indicating copy to clipboard operation
squib copied to clipboard

Do we want Google Sheets integration?

Open andymeneely opened this issue 9 years ago • 8 comments

Much like xlsx and csv, maybe a method to get data from Google Sheets?

Pros:

  • Many people often use Google Sheets more than Excel these days.

Cons:

  • Yet another dependency
  • Chasing Google's ever-changing APIs

Thoughts? Post your votes here!

andymeneely avatar Mar 24 '15 19:03 andymeneely

I would love this! Im building our game with a team and we're using google sheets, I've been having to periodically download the sheets into csv and copy them to the project. This would be a great addition.

evolve2k avatar Jul 27 '15 11:07 evolve2k

Thanks for the vote!

I should also point out that we had someone write up a workaround for now: http://andymeneely.github.io/squib/doc/file.README.html#Using_Google_Sheets

Let me know if it doesn't work, though. Google keeps changing its apis.

andymeneely avatar Jul 27 '15 13:07 andymeneely

Love the idea. I use sheets for all of my development now.

bcompter avatar Oct 09 '15 19:10 bcompter

It's not looking good for Ruby+Google these days. Google has changed their API and usage rules a lot lately, and I haven't seen any Ruby gems make a concerted effort to keep up.

Google also now requires things like API keys and OAuth, which complicates the process much more than most Squibbers have the stomach for.

But if someone else wants to take that on, it doesn't have to integrate with Squib at all - it could just be a general exporter. I would love to be proven wrong.

andymeneely avatar Oct 09 '15 19:10 andymeneely

perhaps a good time to revisit this issue? https://developers.google.com/sheets/api/quickstart/ruby

yipcma avatar Oct 16 '17 06:10 yipcma

there's also this gem http://www.rubydoc.info/gems/google_drive/GoogleDrive/Spreadsheet

But basically all one needs is a in ruby way of downloading a .csv from google sheet

yipcma avatar Oct 16 '17 06:10 yipcma

Yeah that google_drive gem is the one I was using a while back. I'm glad to see it's back to being regularly updated now.

Honestly, while I know folks would love to have this built into Squib, I'm not quite ready to support it. The OAuth steps, while simple for some folks, can be a little daunting for some and I'm not ready to put the support effort into that.

If someone wants to make this happen, it's easy enough to define your own method that works a lot like the Excel parser. You can always post that as a Gist or on this issue. Or, better yet, you can maintain your own gem called squib_google or something.

If that code gets used a lot and maintaining is easy, then I'd be willing to put it into Squib.

andymeneely avatar Oct 16 '17 16:10 andymeneely

You can use Publish to the web... functionality in Google Sheets to make an url that returns CSV.

In Google Sheets:

  1. File -> Publish to the web...
  2. Pick the sheet you want to publish
  3. Pick the format you want to publish (CSV in this case)
  4. Click Publish
  5. Copy the link that it generates

That link is now something you can curl or directly import from Ruby. Note that it doesn't re-publish immediately, it can take up to a minute or two, so it's not great for rapid iteration. It's usually pretty fast though.

Here's how you'd do it in Squib:

require 'net/http'
uri = URI("https://docs.google.com/spreadsheets/d/e/YOUR_GOOGLE_LINK/pub?gid=0&single=true&output=csv")
data = Squib.csv data: Net::HTTP.get(uri)

It's what I'm using and it works great.

Just say NO to Google APIs!

bbugh avatar Oct 20 '17 01:10 bbugh