klieret / anki-merge-notes

Anki plugin to merge notes.
GNU Affero General Public License v3.0
6 stars 0 forks source link

Error message when updating #7

Closed stnk8 closed 5 years ago

stnk8 commented 5 years ago

I've tried multiple things and cannot get this addon to work, but would love it because I have a project that needs exactly what this does. This is the error I'm getting (the u'expression' field is the field I'm trying to use to find duplicates):

Traceback (most recent call last):
  File "/Users/meghanwhite/Library/Application Support/Anki2/addons/merge_notes_files/merge_notes.py", line 129, in loop
    expr = note[self.match_field]
  File "anki/notes.pyc", line 98, in __getitem__
  File "anki/notes.pyc", line 95, in _fieldOrd
KeyError: u'Expression'
klieret commented 5 years ago

Hi,

thank you for your interest in the addon, sorry for being slow with replying, I was on vacation.

This really sounds like you don't have a field called Expression and you write that your field is called expression (lower case).

This can be changed in the config, did you try that?

Cheers, Kilian

stnk8 commented 5 years ago

I was trying to merge Cloze notes and I initially wrote that the field I want to use is "Text" but that wasn't working so I changed it to "Expression" and that wasn't working either. Both times the add-on and field capitalization was identical. Should I have written it lower case in the add-on?

klieret commented 5 years ago

Should I have written it lower case in the add-on?

No, it should be exactly identical.

But are you sure that all notes that are tagged with either MERGE_FROM or MERGE_TO do indeed have this field? Perhaps you mixed up some notes of another type which do not have this field together with the others?

If this doesn't solve it, I might add some more debugging code that will print out the note where it fails, but this error really seems to be due to the field Expression not being found, so I'm pretty sure this is not a bug.

klieret commented 5 years ago

Ah, but I never actually tried Cloze notes, but would be surprised if they work differently from normal notes.

One more thing, just to make sure: As far as I understand it, if you have multiple cloze deletions for one note, several cards will created for the same note. This addon merges notes (which carry the content), not cards (which represent Question-Answer pairs made from a note). But you probably are aware of this.

stnk8 commented 5 years ago

I had the MERGE_FROM and MERGE_TO tags correct, all of both decks were the exact same note type (a cloze note with about 6 additional fields). I ended up getting a different combine duplicates add-on to work, but it is not near as nice as yours and I definitely see the utility of yours. If there's something I can do to help you debug, let me know. I'll try it once more to confirm I had everything correct

klieret commented 5 years ago

Right, I see (I was just checking to exclude some of the more obvious kinds of fails). This addon started as a quick & dirty one-time thing, but I plan to brush it up in the future, since there seems to be some interest.

Let me add some snippet later that will print the exact note where it fails, perhaps this will help to find out what went wrong.

stnk8 commented 5 years ago

I just tried this again and it worked. Not sure what I was doing wrong. This time I had the field set as "Text" and it seemed to have merged appropriately. I deleted the original add-on and redownloaded so I'm not sure if that had anything to do with it.

klieret commented 5 years ago

Thanks for testing this again!

There were some bugs that I had fixed around 2 weeks ago, but it didn't quite sound like any of the previous issues, so I'm not sure what might have caused it.

Anyway, I'm happy that it works :)

I will close this issue, but feel free to open a new one if other problems arise.