a-flash-deck
a-flash-deck copied to clipboard
any way to import anki decks?
Hi! Is there any way to import flashcard decks from the flashcard app anki?
Hi, no there is no way
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.