zachalmers / Anki_Tagger

Given a pdf lecture guide or folder of such files, this codebase will find and tag the best anki cards within a given deck.
16 stars 7 forks source link

tag_deck.py not tagging decks #3

Open cmahlen opened 1 year ago

cmahlen commented 1 year ago

Thanks for putting this together, it's a really great idea and I'm glad you're sharing it with everyone.

I've been able to generate a .csv with all the cards from the learning guide, but I'm having trouble with the last step where tag_deck.py is supposed to take this .csv and tag an .apkg file. I've never manipulated .apkg files from a python program before, so I'm not really sure how this is supposed to work. When I run tag_deck.py <cards.csv> <deck.apkg>, there are no errors, but nothing happens.

Any help would be greatly appreciated.

zachalmers commented 1 year ago

It basically works as expected. It's manipulating the underlying database file of the apkg to insert the tags. Did you have a specific question?

On Sat, Sep 9, 2023, 10:31 PM cmahlen @.***> wrote:

Thanks for putting this together, it's a really great idea and I'm glad you're sharing it with everyone.

I've been able to generate a .csv with all the cards from the learning guide, but I'm having trouble with the last step where tag_deck.py is supposed to take this .csv and tag an .apkg file. I've never manipulated .apkg files from a python program before, so I'm not really sure how this is supposed to work. Any help would be greatly appreciated.

— Reply to this email directly, view it on GitHub https://github.com/zachalmers/Anki_Tagger/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABV3P6XR7AIDPE2K6KXCUXTXZUQ6NANCNFSM6AAAAAA4R3CK7A . You are receiving this because you are subscribed to this thread.Message ID: @.***>

cmahlen commented 1 year ago

Yes, I should have also added that I can't see any new tags when I import the deck into Anki.

zachalmers commented 1 year ago

Hmmm. I'm not sure but if you made it this far you should be able to debug going thru the code.

On Sun, Sep 10, 2023 at 1:42 PM cmahlen @.***> wrote:

Yes, I should have also added that I can't see any new tags when I import the deck into Anki.

— Reply to this email directly, view it on GitHub https://github.com/zachalmers/Anki_Tagger/issues/3#issuecomment-1712894764, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABV3P6QYRDFN6Z73GV2HEBTXZX3ZXANCNFSM6AAAAAA4R3CK7A . You are receiving this because you commented.Message ID: @.***>

jonathan-kuo11 commented 8 months ago

This seems to be the same error (or a similar error) faced in this reddit thread and documented in AnkiPandas. That is, as described in the documentation, using col.db.execute will not force the database to sync (i.e., update existing cards, despite the presence of the new tags on the cards). I have verified that tags are being added to anki_deck.apkg by inspecting the tags field in SQLite for the addition of tags after running tag_deck.py.

To fix this, you can update the mod field to the current epoch time (at script run) using the time module. This will indicate to anki that the card has been edited since export and needs to be refreshed with new data. Will put in fix shortly. I'm not 100% sure this works, as I think there may have been a discrepancy between number of cards tagged vs. number of cards updated, but will figure it out.