我可以从 .CSV 文件创建 Anki 套牌吗?

Tha*_*ess 42 export csv anki

我可以将我的 CSV 文件转换为 Anki 卡组吗?我在程序中找不到任何选项。

小智 38

桌面Anki版本将允许您导入“由制表符或分号分隔的文本”。使用此选项来选择您的 CSV 文件。打开文件后,您将看到一个对话框,允许您自定义数据的导入方式。其中一项设置是让您选择分隔符的选项。将其更改为逗号,它应该对您有用。

屏幕截图:将 CSV 文件导入 Anki

  • 您还必须为 UTF-8 设置编码 (3认同)

gav*_*koa 17

另一种生成.apkg文件的方法是通过 Python 以编程方式重用桌面版本。延长:

PYTHONPATH=/usr/share/anki: python ...
Run Code Online (Sandbox Code Playgroud)

然后,您可以根据需要调整以下示例:

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)
Run Code Online (Sandbox Code Playgroud)

只要你保持note.guidmodel['id']一样的,你可以导入数据库,并更新不失进步

我的生产代码示例: