Brainyoo to anki convert python script

To convert the Brainyoo xml format to a csv format that is readable by Anki.

As there seemed to be no free solution to some other posts.

Here a python script to do the job:

# /// script
# dependencies = [
#   "pandas",
#   "lxml",
# ]
# ///

import pandas as pd
import argparse
from pathlib import Path


parser = argparse.ArgumentParser("anki-convert")
parser.add_argument("--input", "-i", type=Path)
parser.add_argument("--output", "-o", type=Path)

args = parser.parse_args()

df = pd.read_xml(args.input, xpath=".//Textfilecard")

cols = ["Question", "Answer"]
df = df[cols]

df.to_csv(
    args.output,
    header=False,
    index=False,
    sep=";",
)

save as .py and best to run using uv with uv run --script ...

1 Like