def JxExport2csv(): JxPath = unicode(getSaveFile(mw, _("Choose file to export to"), "","Tab separated text file (.csv)", ".csv")) if not JxPath: return if not JxPath.lower().endswith(".csv"): JxPath += ".csv" if path.exists(JxPath): # check for existence after extension if not askUser("This file exists. Are you sure you want to overwrite it?"): return Ids=[] from database import eDeck for (myType,atom) in User: try: for factId in eDeck.atoms[myType][atom].keys(): Ids.extend(eDeck.states[factId][1].keys()) except: pass from anki.exporting import TextFactExporter JxExport = TextFactExporter(mw.deck) JxExport.limitCardIds = Ids JxExport.exportInto(JxPath) mw.help.showText("Successfully exported " + str(len(Ids)) + " cards")
def JxExport2csv(): JxPath = unicode(getSaveFile(mw, _("Choose file to export to"), "","Tab separated text file (.csv)", ".csv")) if not JxPath: return if not JxPath.lower().endswith(".csv"): JxPath += ".csv" if path.exists(JxPath): # check for existence after extension if not ui.utils.askUser("This file exists. Are you sure you want to overwrite it?"): return import string # Query = u"""select cards.id from facts,cards,fields,fieldModels, models where # cards.factId = facts.id and facts.id = fields.factId and fields.fieldModelId = fieldModels.id and facts.modelId = models.id and # fieldModels.name = "Expression" and models.tags like "%%Japanese%%" and fields.value in (%s) group by cards.id""" % string.join([unicode("'" + Stuff + "',") for Stuff in User])[0:-1] # Ids = mw.deck.s.column0(Query) Ids=[] for (Stuff,Id) in User: Ids.append(Id) from anki.exporting import TextFactExporter JxExport = TextFactExporter(mw.deck) JxExport.limitCardIds = Ids JxExport.exportInto(JxPath) mw.help.showText("Successfully exported " + str(len(Ids)) + " facts")