Anki is a vetted foss flashcards tool with spaced-repetition; however, using the Anki gui to create cards can take a long, long time.
Use this convenient anki_from_csv.py
script to create your own flashcards straight from a csv file in a jiffy : )
To install have python3 and run:
./install_deps.sh
This repo depends on genanki.
-
Create flashcards from
numbers.csv
by running:python3 anki_from_csv.py numbers
-
Open the created
numbers.apkg
file iwth Anki.
Using the anki_from_csv.py
script is very simple two step process, see steps below:
With vim/emacs or preferred editor create a csv file.
See example below, mandarin_numbers.csv
:
1,一,yī
2,二,èr
3,三,sān
4,四,sì
5,五,wǔ
6,六,liù
7,七,qī
8,八,bā
9,九,jiǔ
10,十,shí
Run the following replacing <vocab_set_basename>
with your vocab list:
python3 anki_from_csv.py <vocab_set_basename>
For example
python3 anki_from_csv.py mandarin_numbers
Make sure to omit the extension .csv
This last example will create a mandarin_numbers.apkg
which you can open with any Anki app : )
There are just two sections you'll need to modify if you'd like to add more fields or reduce to just two.
We'll show below an example for moving from English to Mandarin to just English to say French.
create french_numbers.csv
1,un
2,deux
3,Trois
4,quatre
5,cinq
6,six
7,Sept
8,huit
9,neuf
10,Dix
before:
my_model = genanki.Model(
1000000000,
deck_name,
fields=[
{'name': 'English'},
{'name': 'Pinyin'},
{'name': 'Simplified'},
],
templates=[
{
'name': 'Card Template 1',
'qfmt': '<center style="font-size:30px">{{English}}</center>',
'afmt': '{{FrontSide}} <hr> <p align=center style="font-size:30px"> {{Simplified}} <br /> {{Pinyin}}</p>',
},
])
after:
my_model = genanki.Model(
1000000000,
deck_name,
fields=[
{'name': 'English'},
{'name': 'French'},
],
templates=[
{
'name': 'Card Template 1',
'qfmt': '<center style="font-size:30px">{{English}}</center>',
'afmt': '{{FrontSide}} <hr> <p align=center style="font-size:30px"> {{French}}</p>',
},
])
before
# english, pinyin, simplified
with open(csv_name, newline='') as csvfile:
anki_reader = csv.reader(csvfile)
for row in anki_reader:
new_card = genanki.Note(
model = my_model,
fields = [row[0],row[1],row[2]])
my_deck.add_note(new_card)
my_package = genanki.Package(my_deck)
my_package.write_to_file(package_name)
after
# english, pinyin, simplified
with open(csv_name, newline='') as csvfile:
anki_reader = csv.reader(csvfile)
for row in anki_reader:
new_card = genanki.Note(
model = my_model,
fields = [row[0],row[1]])
my_deck.add_note(new_card)
my_package = genanki.Package(my_deck)
my_package.write_to_file(package_name)
python3 anki_from_csv.py french_numbers
and you should now have apkg called french_numbers.apkg
ready to import to Anki from and Anki app : )