anki-remote-decks icon indicating copy to clipboard operation
anki-remote-decks copied to clipboard

Sync using google sheets instead of google docs

Open senteix2 opened this issue 6 years ago • 18 comments

not a bug but a feature request, it would be easier to have cards in google sheets than in google docs, i have some that i use with flippity but i want to use them with anki , so this feature would be great , i will create my own fork to add that meanwhile

senteix2 avatar Oct 04 '19 00:10 senteix2

The main reason I have not added this feature is that I've personally never used the CSV / sheets format to import or export cards. I don't really understand people's workflow tbh.

Does importing via CSV require the user to map the columns onto note fields? Does a single CSV file support multiple different card types? How would people normally add images for the cards?

I would want to have a good idea of what people expect already before adding anything that needs to be supported long term

c-okelly avatar Oct 04 '19 04:10 c-okelly

csv/sheets format is similar to a table database so the workflow could be as you defined it . it doesnt have to be a more complex format of what you already have. but google sheet is not equal to csv in the sense that a txt is not equal to a google doc file . yeah they both share very similar format but with google sheets you also have the ability to publish the document as webpage similar as what you use in google docs. Q: Does importing via CSV require the user to map the columns onto note fields? A: it could but you can also use the same format that you are already using in the google docs for google sheets (because you can also publish google sheet as a webpage and it will create an html file like the google docs) , but you will have to create different parser method I guess.

Q: Does a single CSV file support multiple different card types? Does a single CSV file support multiple different card types? A: Yes, you can have a column type like a generic table (one very similar at what you have on google docs would be) type|value , for example: Q|capital of Peru A|Lima A|the city of the kings Q|capital of USA A|New York A|the city of wall street

Q: How would people normally add images for the cards? A: in anki ? i don't know, but in google sheets you can just add a formula like =IMAGE(url) and it will load the image inside the cell

senteix2 avatar Oct 08 '19 00:10 senteix2

I will start having a look at this so. It think it makes sense at a high level but definitely needs to be fleshed out more.

I'm also concerned with trying to support to may different formats but this one does make sense

c-okelly avatar Oct 09 '19 05:10 c-okelly

great, let me know if you need any help :D

senteix2 avatar Oct 14 '19 14:10 senteix2

Hey,

I have had not had any time to work on this as I have been away currently. If you want to have crack at starting it let me know and I'll point you in the right direction.

c-okelly avatar Oct 31 '19 16:10 c-okelly

Hello, i already got it working with google sheets , i was able to crack your code pretty easily, i made a import.py file that I use for another project ( i was creating my own flashcard app ). I can share the changes if you want ,

senteix2 avatar Dec 06 '19 13:12 senteix2

Please do I would be interested in having a look!

I have not had any time to work on any new features recently as have been looking for a job but should be more free over the next few weeks!

c-okelly avatar Dec 07 '19 01:12 c-okelly

Hello, i already got it working with google sheets , i was able to crack your code pretty easily, i made a import.py file that I use for another project ( i was creating my own flashcard app ). I can share the changes if you want ,

I would be really interested in having this feature! Any chance you could add it to the addon somehow?

heaneySam avatar Feb 10 '20 14:02 heaneySam

Q: Does a single CSV file support multiple different card types? Does a single CSV file support multiple different card types? A: Yes, you can have a column type like a generic table (one very similar at what you have on google docs would be) type|value , for example: Q|capital of Peru A|Lima A|the city of the kings Q|capital of USA A|New York A|the city of wall street

Why not just make it into separate columns?

ID Q A Tag(s) Img Hint UUID What is… Answer [empty] image phrase

Do you really need to take the detour via publishing as HTML?

l-g avatar Feb 23 '20 10:02 l-g

I'm interested in this feature. Instead of publishing a sheet and parsing HTML, you can just creating a sharing link for the sheet, get the CSV download link for the sheet, and then use standard CSV parsing libraries. Alternatively, you could just pass the CSV to Anki's CSV importer (anki.importing.TextImporter), but the behavior of this might differ from the behavior of importing a Google Doc. Personally, I'd be fine with it.

An alternative is to use the Google Drive API, which would allow you to have private sheets, and the extension could provide an interface for selecting the sheet they want instead of needing to grab the URL. But that's more work that's probably not necessary.

The format of the sheet should be each column is one field of the note.

gsingh93 avatar Apr 14 '20 06:04 gsingh93

I created this to sync Google Sheets with Anki: https://github.com/gsingh93/anki-csv-importer. Feel free to incorporate any of that code into this project if it helps.

gsingh93 avatar May 05 '20 01:05 gsingh93

Thanks I will have a look!

c-okelly avatar May 05 '20 05:05 c-okelly

Google Sheets has a GoogleTranslate formula, so all my vocabulary cards are actually in google sheets. Would love to have this plugin for Google Sheets also.

nervusvagus avatar Jul 07 '20 10:07 nervusvagus

There will probably be a closed beta of this coming up very soon for those interested. Mainly so I can get some feedback before a general release.

I'll comment more about it when I have a proper update.

If interested just like this comment

c-okelly avatar Jul 07 '20 17:07 c-okelly

I’m interested! Sign me up!

heaneySam avatar Jul 07 '20 19:07 heaneySam

Indeed, I have been looking for the same feature. I also prepare my decks in Google Sheets, with Front in column A and back in column B. Before reading this thread I made a short Google Apps script copying the content of the Google Sheet with my cards into a Google Doc in the format of your plugin. This is the script:

function JapaneseWordsFromSheetToDoc() {

// Opens spreadsheet by its ID var spreadsheet = SpreadsheetApp.openById("<Replace with you Spreadsheet ID>");

// Get the name of the spreadsheet var name_of_sheet = spreadsheet.getName(); var OriginalSheet = spreadsheet.getSheetByName('Anki');

// Opens doc by its ID var doc = DocumentApp.openById("<Replace with you Doc ID>"); var name_of_doc = doc.getName(); var doc_body = doc.getBody();

// Get the last non empty row in the column A of the excel var Direction=SpreadsheetApp.Direction; var aLast =OriginalSheet.getRange("A"+(OriginalSheet.getLastRow()+1)).getNextDataCell(Direction.UP).getRow();

//****************************************************************************************************

// copy all cards into the Doc for (i = 2; i <= aLast; ++i){

var SheetRange = OriginalSheet.getRange(i,1); var FrontValue = SheetRange.getValue(); var front = doc_body.appendListItem(FrontValue).setNestingLevel(0).setGlyphType(DocumentApp.GlyphType.BULLET);

var SheetRange = OriginalSheet.getRange(i,2); var BackValue = SheetRange.getValue(); var back = doc_body.appendListItem(BackValue).setNestingLevel(1).setGlyphType(DocumentApp.GlyphType.BULLET);

}

But it doesn't always work well. E.g. I don't manage to have the both levels formatted as bulleted list, and after changing it manually, the plugin still doesn't import all the cards. This is the link to the doc, for your reference, if you want to check what is going wrong. https://docs.google.com/document/d/e/2PACX-1vRrbKl_jmG55EHGEAjUJMUonWPmlbmjlsVUgwNuSRtngFLwHKLQFcDpqvx_meeNCxtbLrGBp3zNImwb/pub

I'll definitely be in to test if you extend your plugin to Google Sheets!

iltempovola avatar Sep 02 '20 07:09 iltempovola

@c-okelly I'd love to try it

erickhun avatar Dec 16 '20 22:12 erickhun

would be great if add-on could also add images from Google Sheets but I dont think its possible

pagkly avatar Feb 06 '21 03:02 pagkly