-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Cause Duplicates #32
Comments
Hi @namurai21. Thanks a lot for reporting this. Could you offer some more details of how to reproduce this issue? E.g. a small code snippet that demonstrates this, etc. Quite busy at the moment, so this would help me to figure this out faster. |
Thanks for the response @klieret. Here is a modified snippet of my code: New_notes = [['lexeme', 'new example sentence 1', 'new example sentence 2' , so on..]]
col = Collection(anki_path, user=user_name)
ntcol = col.notes.copy()
ntcol = ntcol.loc[(ntcol['nmodel'] == "NoteEnglish")]
ntcol.fields_as_columns(inplace=True)
for each_note in new_notes:
lex = each_note[0] # The top Field
sens = [1:] #I use separate function to produce list of tuples like "[('nfld_SEN1', 'new example setence 1')...]
for sen in sens:
nid = ntcol.loc[ntcol["nfld_LEX"] == lex].index.tolist()[0]
ntcol.loc[nid, sen[0]] = sen[1]
ntcol.fields_as_list(inplace=True)
col.notes.update(ntcol)
col.summarize_changes()`
col.write(modify=True, delete=False) The "summarize_changes" and "was_modified" both show the correct update, and the changes do seem to work initially when logging back in Anki (the fields are updated accordingly with new values). However, the updated notes soon duplicate the cards for each updated field, e.g. two identical "Card 4" cards. I use Conditional Replacement for Card Generation for these cards, and duplicates only occur for cards that were previously empty (therefore cards non-existent) before updates made via Ankipandas. I suspect this is the reason for this result. Finally, I'm still a novice in dealing with dataframes, and I apologize in advance for any simple mistake. |
Thanks for the code snippet! I was a bit too busy to look at this so far; I'll definitely have a look at it this week. Sorry for being slow! |
Okay, I just looked at the code snippet. Let me summarize what I understood you're trying to do
When you go in Anki's browser, what does it say for the card types of the duplicated cards? You might also look into this by right-clicking the card and selecting |
Your summary is exactly what I meant. Thank you. I have tried my script after the recent upgrade, and it seems that the problem has been resolved! The changes made in "nflds" successfully creates/deletes cards (reflective of Selective Card Generation) without any duplicates. It may have been a mistake in my code, but nonetheless, thank you, again. Therefore, it may now be irrelevant, but to answer your question, the duplicates did have the same ID, Note ID, and Card Type. |
The problem persists. |
Sorry for not giving any updates on this, I'm currently too busy. I hope I will get to this eventually. |
The "col.notes.update()" seems to duplicates cards when editing values in "nflds". E.g. two exact "Card 1" from same Note (nid).
The text was updated successfully, but these errors were encountered: