quizlet2anki: Refactor

It now uses CJK characters instead of repeated ASCI characters, since
they are not used in my cards.
This commit is contained in:
Simon Bruder 2021-03-15 19:13:21 +01:00
parent 712baf2b4f
commit 3b5459b2b2
Signed by: simon
GPG key ID: 8D3C82F9F309F8EC

View file

@ -1,22 +1,20 @@
#!/usr/bin/env nix-shell #!/usr/bin/env nix-shell
#!nix-shell -i python3 -p python3 #!nix-shell -i python3 -p python3
# I want to use Anki instead of Quizlet. However, Quizlet only provides a very # 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 # 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). # column or row separator (e.g. if you have multiple lines in one field).
# This script takes unquoted data with uncommon separators (|||||| for columns, # This script takes unquoted data with separators that dont exist on the cards
# \n------\n for rows) and exports it as a more usable csv (quoted, cols # (世 for columns, 界 for rows) and exports it as a more usable csv (quoted,
# separated by \t, rows separated by \n) # cols separated by tab, rows separated by newline).
import sys import sys
outfile = sys.argv[1] outfile = sys.argv[1]
quizlet_output = sys.stdin.read() quizlet_output = sys.stdin.read()
maybe_tsv = ( maybe_tsv = '"' + quizlet_output.replace("", '"\t"').replace("", '"\n"')
'"' + quizlet_output.replace("||||||", '"\t"').replace("\n------\n", '"\n"') + '"'
)
maybe_tsv = maybe_tsv[:-2] maybe_tsv = maybe_tsv[:-2]