From 3b5459b2b2b8adbed1667c779307a1bce268137e Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Mon, 15 Mar 2021 19:13:21 +0100 Subject: [PATCH] quizlet2anki: Refactor It now uses CJK characters instead of repeated ASCI characters, since they are not used in my cards. --- quizlet2anki.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/quizlet2anki.py b/quizlet2anki.py index 457955f..8e7fc08 100755 --- a/quizlet2anki.py +++ b/quizlet2anki.py @@ -1,22 +1,20 @@ #!/usr/bin/env nix-shell #!nix-shell -i python3 -p python3 # I want to use Anki instead of Quizlet. However, Quizlet only provides a very -# limited “export” functionality, that exports something like csv, but does nut +# limited “export” functionality, that exports something like csv, but does not # support quoting. So it will fail if your separation character is either your # column or row separator (e.g. if you have multiple lines in one field). -# This script takes unquoted data with uncommon separators (|||||| for columns, -# \n------\n for rows) and exports it as a more usable csv (quoted, cols -# separated by \t, rows separated by \n) +# This script takes unquoted data with separators that don’t exist on the cards +# (世 for columns, 界 for rows) and exports it as a more usable csv (quoted, +# cols separated by tab, rows separated by newline). import sys outfile = sys.argv[1] quizlet_output = sys.stdin.read() -maybe_tsv = ( - '"' + quizlet_output.replace("||||||", '"\t"').replace("\n------\n", '"\n"') + '"' -) +maybe_tsv = '"' + quizlet_output.replace("世", '"\t"').replace("界", '"\n"') maybe_tsv = maybe_tsv[:-2]