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


31

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

Answers:


26

桌面Anki版本允许您导入“ 用制表符或分号分隔的文本 ”。使用此选项选择您的CSV文件。打开文件后,将显示一个对话框,您可以自定义如何导入数据。其中一项设置是允许您选择定界符的选项。将其更改为逗号,它将为您工作。

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


3
另外,您还必须为UTF-8设置编码

1
可以用于将新卡插入现有卡座吗?
Septagram'6

你是怎么做到的?我有一个带有“ Note ID”的卡片组。但是,它不会出现在映射选项中:只是“前”,“后”或“忽略”。
卡兹(Kaz)

8

.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.guidmodel['id']同样你可以导入数据库 更新不失进步

我的生产代码示例:

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.