Guidance for a program

Background : I am taking a lot of time for preparing anki cards.
Planning to learn some coding or whatever it takes to generate a program that will enable me to make simple question answer format cards in massive cloze note type.

This is how I dream it will be at the end

1)we will insert a content pdf to the program.
2) the program will generate one word question and answer in massive cloze note types.
3) we can read the pdf and then use anki to learn them .

Any form of mentoring will be appreciated.

NB: at present i have some rudimentary python background, I learned C, C++ during my school days .

The genanki package most likely has everything you’ll need. The documentation is short and concise.

For illustration, I’ve copied a simple program I use to create a dynamic cloze deck in Python - I’ve made some comments for an easier start.

Starting out, you’ll probably want to store your note type (HTML_front, HTML_back, CSS) in separate files, then read them into your script:

    # Get note html and css
    with open('card-type/styling.css', 'r') as file:
        styling =
    with open('card-type/front.html', 'r', encoding='utf-8') as file:
        front =
    with open('card-type/back.html', 'r', encoding='utf-8') as file:
        back =


    # Create cloze note type
    note_type = genanki.Model(
        1607892320, 'Notetype name',
        fields=[{'name': field} for field in fieldnames],  # fieldnames is a list of strings you define beforehand
        templates=[     # html from template folder
                'name': 'Cloze-Card',
                'qfmt': front,
                'afmt': back,
        css = styling,  # css from template folder


    # Create deck
    deck = genanki.Deck(2059499999, 'Your Deck Name')

    # Custom GUID - set first field as unique identifier
    class MyNote(genanki.Note):
        def guid(self):
            return genanki.guid_for(self.fields[0])


    # You'll most likely have some kind of loop to create the notes for the deck
    for i in range(x):

        my_note = MyNote(
            model=note_type,    # created above
            fields= ['actual', 'field', 'values', '{{c1::with}}', 'clozes', 'or', 'without']
            tags = ['list', 'of', 'tags']

        # Add note to deck - move on

    # Write deck to anipackage file


I cannot offer any mentoring right now, but if you have any further questions I’ll do my best to help.


Thanks bro

I second the recommendation of genanki.


Note that pdf documents are not particularly easy to parse with python. If you can collect your data into an easier format, such as text, csv, xml, json, or even html, it will be much, much easier to write a python program to build the Anki deck than if your data is in a pdf document.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.