arturdryomov / gambit

No junk, just flashcards
Apache License 2.0
22 stars 8 forks source link

Import Google Sheet document as a deck #8

Open Co2p opened 8 years ago

Co2p commented 8 years ago

Import Google Sheet document as a deck. First column is the question and second column is the answer with the rows representing one card per row

Co2p commented 8 years ago

https://developers.google.com/drive/android/intro

arturdryomov commented 8 years ago

Google Sheets does not have any usable API as far as I know. Google Drive API operates on the file-level, basically excluding any content manipulations.

Co2p commented 8 years ago

I'm going to take a look at it, see if it's possible. I think it would allow easier editing and sharing of decks, but like you said it might not work.

arturdryomov commented 8 years ago

I’ll probably list options available at this point. In the process of writing them down I decided that maybe it is time to revisit some of them. Anyway.

GData Java Client

Provides APIs in the ready-to-use format, but essentially is deprecated in favour of Google APIs Client for Java.

Google APIs Client for Java

Kind of actively developed, but has two major downfalls.

Google Play Services

It is mostly nice and is used for the current backup file-based system. Unfortunately Drive API there operates only on file-level, i. e. I have no access to any structural data in either Docs, Sheets or whatever.

Conversion

Basically create a MS Office or OpenDocument sheet and upload or download it from Drive with conversion to or from the native Sheet. But this solution is not perfect as well—there are not many thin and not bloated Java libraries which afford sheet file creation and parsing. Plus, there are weird limitations, like both .xslx and .ods will limit sheet name to 31 symbols no matter what and libraries actually follow these rules. Damn, just try to create a Google Sheet, name a sheet inside the document with 50 symbols, then download it as Microsoft Excel and OpenDocument, then upload it to Google Drive and choose Open with Google Sheets at the context menu. Both imported documents will truncate the sheet name length from 50 symbols to 31. Because reasons.

Dumb Conversion

Treat each deck contents as a CSV file and all decks as a directory with CSV files. But I really, really hate this solution. One of main goals of Gambit is simplicity. This solution is against any end user good UX at all. Even personally I don’t want to know about any files when I can edit it either online or as a one modern format—like .ods or .xlsx.

Co2p commented 8 years ago

looks like you can use a combination of the Drive API (for deleting and creating files) the Sheets API for modifying data and there seems to be a API client to help, I'll have a go and make a pull request if i manage.

Links: https://developers.google.com/drive/android/create-file https://developers.google.com/google-apps/spreadsheets/setup https://github.com/google/google-api-java-client