Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Anki CSV Importer not working - KeyError: 'Front'

$
0
0

I am trying to use the Anki CSV Importer to import a CSV file I have into an Anki deck.

My CSV file has 2 columns (Answer, Question) and, as of right now, 2628 rows (whose number will grow with time), looking like this:

Answer, Questiontranslation1,word1translation2,word2[etc]

I have added the AnkiConnect add-on to Anki, as recommended by the author of the code on Github (I am running it on Windows 11).

I am also making sure an instance of Anki is running before I execute the Anki CSV importer.

My program crashes, here is the exception I am getting:

Starting main loop...JS error :1 Uncaught TypeError: Cannot read properties of null (reading 'offsetHeight')  File "<string>", line 1, in <module>  File "aqt", line 509, in run  File "aqt", line 717, in _run  File "C:\Users\User\AppData\Roaming\Anki2\addons21\2055492159\__init__.py", line 93, in advance    self.server.advance()  File "C:\Users\User\AppData\Roaming\Anki2\addons21\2055492159\web.py", line 136, in advance    self.advanceClients()  File "C:\Users\User\AppData\Roaming\Anki2\addons21\2055492159\web.py", line 151, in advanceClients    self.clients = list(filter(lambda c: c.advance(), self.clients))  File "C:\Users\User\AppData\Roaming\Anki2\addons21\2055492159\web.py", line 151, in <lambda>    self.clients = list(filter(lambda c: c.advance(), self.clients))  File "C:\Users\User\AppData\Roaming\Anki2\addons21\2055492159\web.py", line 68, in advance    self.writeBuff += self.handler(req)  File "C:\Users\User\AppData\Roaming\Anki2\addons21\2055492159\web.py", line 202, in handlerWrapper    body = json.dumps(self.handler(params)).encode('utf-8')  File "C:\Users\User\AppData\Roaming\Anki2\addons21\2055492159\__init__.py", line 130, in handler    api_return_value = methodInst(**params)  File "C:\Users\User\AppData\Roaming\Anki2\addons21\2055492159\__init__.py", line 543, in createDeck    self.startEditing()  File "C:\Users\User\AppData\Roaming\Anki2\addons21\2055492159\__init__.py", line 214, in startEditing    self.window().requireReset()  File "aqt.main", line 864, in requireResetrequireReset() is obsolete; please use CollectionOp()[+] Adding 0 new notes and updating 2627 existing notesTraceback (most recent call last):  File "S:\3-Languages\xlsm2csv2anki\anki-csv-importer.py", line 363, in <module>    main()  File "S:\3-Languages\xlsm2csv2anki\anki-csv-importer.py", line 351, in main    send_to_anki_connect(  File "S:\3-Languages\xlsm2csv2anki\anki-csv-importer.py", line 175, in send_to_anki_connect    front = n['fields']['Front'].replace('"', '\\"')            ~~~~~~~~~~~^^^^^^^^^KeyError: 'Front'C:\Users\User>taskkill /IM anki.exe /FsERROR: Invalid argument/option - '/Fs'.Type "TASKKILL /?" for usage.C:\Users\User>

I don't understand why the field "Front" should be available on the variable "n", I have checked the code and don't understand what this should be referring to and why it is not getting generated when I execute it.

Also, my deck in Anki is currently empty, so I am not sure why it is stating "0 new notes and updating 2627 existing notes".

I have tried debugging the code by providing the args as manual input, however, I don't understand the issue.


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>