Answers:
桌面Anki版本允许您导入“ 用制表符或分号分隔的文本 ”。使用此选项选择您的CSV文件。打开文件后,将显示一个对话框,您可以自定义如何导入数据。其中一项设置是允许您选择定界符的选项。将其更改为逗号,它将为您工作。
.apkg
通过使用Python重用桌面版本以编程方式生成文件的另一种方法。延伸:
PYTHONPATH=/usr/share/anki: python ...
并运行脚本(当然,您应该根据需要对其进行调整):
import anki
from anki.exporting import AnkiPackageExporter
collection = anki.Collection(os.path.join(TMPDIR, 'collection.anki2'))
deck_id = collection.decks.id(FBASENAME + "_deck")
deck = collection.decks.get(deck_id)
model = collection.models.new(FBASENAME + "_model")
model['tags'].append(FBASENAME + "_tag")
model['did'] = deck_id
model['css'] = """
.card {
font-family: arial;
font-size: 20px;
text-align: center;
color: black;
background-color: white;
}
.from {
font-style: italic;
}
"""
collection.models.addField(model, collection.models.newField('en'))
collection.models.addField(model, collection.models.newField('ru'))
tmpl = collection.models.newTemplate('en -> ru')
tmpl['qfmt'] = '<div class="from">{{en}}</div>'
tmpl['afmt'] = '{{FrontSide}}\n\n<hr id=answer>\n\n{{ru}}'
collection.models.addTemplate(model, tmpl)
tmpl = collection.models.newTemplate('ru -> en')
tmpl['qfmt'] = '{{ru}}'
tmpl['afmt'] = '{{FrontSide}}\n\n<hr id=answer>\n\n<div class="from">{{en}}</div>'
collection.models.addTemplate(model, tmpl)
model['id'] = 12345678 # essential for upgrade detection
collection.models.update(model)
collection.models.setCurrent(model)
collection.models.save(model)
note = anki.notes.Note(collection, model)
note['en'] = "hello"
note['ru'] = u"[heləʊ]\nint. привет"
note.guid = "xxx1"
collection.addNote(note)
note = collection.newNote()
note['en'] = "bye"
note['ru'] = u"[baɪ]\nint. пока"
note.guid = "xxx2"
collection.addNote(note)
export = AnkiPackageExporter(collection)
export.exportInto(FONAME)
只要你保持note.guid
和model['id']
同样你可以导入数据库 更新卡不失进步!
我的生产代码示例: