question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

All cards added to the first deck name when multiple decks are added to a package.

See original GitHub issue

Dear KerrickStaley,

Thank you for sharing your library. I think I might have found an issue.

Example code:

data = {
    'deck1':
    [{
    'a': 'content deck 1 a1',
    'b': 'content deck 1 b1'
    },
    {
    'a': 'content deck 1 a2',
    'b': 'content deck 1 b2'
    }],
    'deck2':
     [{
    'a': 'content deck 2 a1',
    'b': 'content deck 2 b1'
    },
    {
    'a': 'content deck 2 a2',
    'b': 'content deck 2 b2'
    }],
    'deck3':
     [{
    'a': 'content deck 3 a1',
    'b': 'content deck 3 b1'
    },
    {
    'a': 'content deck 3 a2',
    'b': 'content deck 3 b2'
    }]  
}

# Create the model
a_to_b = genanki.Model(
    2043134337, # unique identifier
    'a-to-b', # human readable name
    fields = [ 
    {'name': 'a'},
    {'name': 'b'},
    ],
    templates=[
    {
      'name': 'Card 1',
      'qfmt': '{{a}}',
      'afmt': '{{FrontSide}}<hr id="answer">{{b}}',
    },
    ]
)

decks = []
for deck_name in data:
    deck = genanki.Deck(
      2043134340,
      deck_name
    )

    # Add the notes
    for note in data[deck_name]:
      note = genanki.Note(
        model=a_to_b,
        fields=[note.get('a',''),
                note.get('b',''),
               ])
      deck.add_note(note)
    decks.append(deck)

# Create the file
genanki.Package(decks).write_to_file('output.apkg')

When I then load this apkg file into Anki, Anki adds all 6 cards that should be in deck1, deck2 and deck3 into only deck1.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
sciencemanxcommented, Nov 30, 2018

PR submitted and complete #20. Please review

0reactions
Karl2222commented, Jun 1, 2021

Hello sciencemanx,

I got the issue again. But the behavior is different

“When I then load this apkg file into Anki, Anki adds all 6 cards that should be in deck1, deck2 and deck3 into only deck3.”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Standard 52-card deck - Wikipedia
The standard 52-card deck of French-suited playing cards is the most common pack of playing cards used today. In English-speaking countries it is...
Read more >
Card copies in multiple decks? - Fluent Forever
My idea is to create two separate decks. The first deck would have two cards per word - image:sound&pinyin and character:sound/pinyin (so ...
Read more >
Programming Example: Card, Hand, Deck
In a typical card game, each player gets a hand of cards. The deck is shuffled and cards are dealt one at a...
Read more >
Filtered Decks - Anki Manual
Display those cards first, that you have most recently added to the deck. (This is the opposite of 'Order added'.) Relative overdueness. Display...
Read more >
Anki for Med School: Structuring Decks and Tags - YouTube
This video describes one method to systematically organize Anki decks related to medical school coursework. Check out some of my other ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found