Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

any way to import anki decks? #17

Open
justpeanuts opened this issue Aug 21, 2023 · 2 comments
Open

any way to import anki decks? #17

justpeanuts opened this issue Aug 21, 2023 · 2 comments

Comments

@justpeanuts
Copy link

Hi! Is there any way to import flashcard decks from the flashcard app anki?

@rh-id
Copy link
Owner

rh-id commented Aug 21, 2023

Hi, no there is no way

@yuwash
Copy link

yuwash commented Dec 26, 2023

I don’t know about Anki but some apps (notably quizlet, cram.com) allow exporting cards as csv/tsv. For the simplest (text-only) flashcards, you can create a file that can be imported by the app using the following little function (which you can easily amend for other input formats):

    with open(csv_file) as f:
        lines = f.readlines()
    deck_uid = -812177  # Doesn’t matter much
    cards = []
    for line in lines:
        question, answer = line.split("\t")
        cards.append(
            {
                "id": 1,
                "deckId": 1,
                "ordinal": 0,
                "question": question,
                "questionImage": "",
                "questionVoice": "",
                "answer": answer,
                "answerImage": "",
            }
        )

    print(
        json.dumps(
            [
                {
                    "serialVersionUID": deck_uid,
                    "deck": {
                        "id": 1,
                        "name": deck_name,
                        "createdDateTime": "1703530960604",
                        "updatedDateTime": "1703530960604",
                    },
                    "cardList": cards,
                }
            ]
        )
    )

Write the output of the script into a file called Decks.json and then make a zip archive containing only that file.

I’m rather new to this app but just made this work by looking at an export file that the app produces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants