c-okelly / anki-remote-decks

Addon for Anki - Creating remote decks in Google Docs
https://ankiweb.net/shared/info/911568091
MIT License
71 stars 15 forks source link

Sync using google sheets instead of google docs #20

Open senteix2 opened 5 years ago

senteix2 commented 5 years ago

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

c-okelly commented 5 years ago

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

senteix2 commented 5 years ago

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

c-okelly commented 5 years ago

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

senteix2 commented 5 years ago

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

c-okelly commented 4 years ago

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.

senteix2 commented 4 years ago

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 ,

c-okelly commented 4 years ago

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!

heaneySam commented 4 years ago

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?

l-g commented 4 years ago

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?

gsingh93 commented 4 years ago

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 commented 4 years ago

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.

c-okelly commented 4 years ago

Thanks I will have a look!

nervusvagus commented 4 years ago

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.

c-okelly commented 4 years ago

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

heaneySam commented 4 years ago

I’m interested! Sign me up!

iltempovola commented 4 years ago

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("");

// 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(""); 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!

erickhun commented 3 years ago

@c-okelly I'd love to try it

pagkly commented 3 years ago

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