Closed brownbat closed 4 years ago
Thanks a lot for letting me know!
Hmm, that's strange. Perhaps that's a similar error to https://github.com/klieret/AnkiPandas/issues/36 and has to do with changes introduced by the Anki 2.1.26/2.1.28beta.
What Anki version are you using? And are you running this on a completely empty collection or are there already some cards/notes/models?
And could you run the following snippet:
import ankipandas
from ankipandas.raw import get_info
col = ankipandas.Collection()
model_info = get_info(col.db)["models"]
print(type(model_info))
print(model_info)
and send me the output?
This would help me to track down what's happening there.
(I'm on holidays though, so I might be a bit slow to reply)
I've only tried building the latest build of Anki on my VM, so I've used the collection with v.1.3.1+ here. It's not an empty or new deck, it was exported from a deck originally used in Anki 2.1.26.
Looks like models is getting an empty string, not sure why.
thomas@thomas-VirtualBox:~/PycharmProjects/anki$ python3
Python 3.8.2 (default, Jul 16 2020, 14:00:26)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ankipandas
>>> from ankipandas.raw import get_info
>>> col = ankipandas.Collection()
INFO: Searching for database. This might take some time. You can speed this up by specifying a search path or directly entering the path to your database.
WARNING: The search will stop at the first hit, so please verify that the result is correct (for example in case there might be morethan one Anki installations)
INFO: Loaded db from /home/thomas/.local/share/Anki2/User 1/collection.anki2
>>> model_info = get_info(col.db)["models"]
>>> print(type(model_info))
<class 'str'>
>>> print(model_info)
>>>
That's a one line gap there, doesn't appear to contain a space or anything. After that, to confirm the collection has something in it, I ran col.cards just to be sure, here's the first line:
>>> col.cards
nid cord cmod cusn ... cleft codue cdeck codeck
cid ...
1589630886942 1589220255215 2 1597756833 -1 ... 0 0
...
No rush for my benefit. I think you're right on my other comment, I need some other way to generate a set of test decks, maybe genanki.
Good luck with this one, let me know if there's anything else I can do to help test.
Ah, I've updated to the newest stable release and see what's going on there. Basically the way anki saved the configuration in the database has changed slightly, but it should be possible to adapt.
The new version of ankipandas should now support the new db format.
If you want, you could help by testing if it works for you.
To update ankipandas, do
pip3 install --user --upgrade ankipandas
col.notes
now works like a charm.
Your earlier testing recommendations don't survive, but maybe you know that already.
>>> get_info(col.db)
{1: {'crt': 1597392000, 'mod': 1598225343106, 'scm': 1598220616405, 'ver': 15, 'dty': 0, 'usn': 0, 'ls': 0, 'conf': '', 'models': '', 'decks': '', 'dconf': '', 'tags': ''}}
So I have to subscript that get_info call with [1]["models"] instead of just "models", and it ends up empty.
But col.notes and col.cards have integers in nmod and cmod, and col.notes has strings in nmodel that track to my note types, so there are models floating around in there. Maybe that means everything's working as expected.
Output on col.cards and col.notes, for the curious.
>>> col.cards
nid cord cmod cusn ctype cqueue cdue civl cfactor creps clapses cleft codue cdeck codeck
cid
1589630886942 1589220255215 2 1597756833 -1 learning new 718 0 2500 0 0 0 0 Korean3 Transcription1 Vocab
1589630886944 1589220255216 2 1597756833 -1 learning new 2046 0 2500 0 0 0 0 Korean3 Transcription1 Vocab
1589630886946 1589220255217 2 1597756833 -1 learning new 1459 0 2500 0 0 0 0 Korean3 Transcription1 Vocab
1589630886950 1589220255220 2 1597756832 -1 relearn due -99971 32 2900 3 0 0 19 Filtered Deck 1 Korean3 Transcription1 Vocab
1589630886952 1589220255221 2 1597756833 -1 learning new 965 0 2500 0 0 0 0 Korean3 Transcription1 Vocab
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
1597361145241 1597361136294 2 1597756833 -1 learning new 1729 0 0 0 0 0 0 Korean3 Transcription2 Phrases
1597361145244 1597361136295 2 1597756833 -1 learning new 691 0 0 0 0 0 0 Korean3 Transcription2 Phrases
1597361145247 1597361136296 2 1597756833 -1 learning new 2983 0 0 0 0 0 0 Korean3 Transcription2 Phrases
1597361145250 1597361136297 2 1597756833 -1 learning new 2513 0 0 0 0 0 0 Korean3 Transcription2 Phrases
1597361145253 1597361136298 2 1597756833 -1 learning new 1061 0 0 0 0 0 0 Korean3 Transcription2 Phrases
[5330 rows x 15 columns]
>>> col.notes
nguid nmod nusn ntags nflds nmodel
nid
1589220255215 u>q;4An(mn 1595335887 -1 [modified] [νκ΅, Korea, The formal name of the country is ... HTSK Vocab
1589220255216 gx^T0_ayJs 1595335887 -1 [modified] [λμ, city, , λλμ = a large city<br>μ λμ = a new... HTSK Vocab
1589220255217 Aua_I=*8L( 1595335887 -1 [duplicate, modified] [μ΄λ¦, name, , μ΄λ¦μ΄ λμμ? = What is your name?<br>... HTSK Vocab
1589220255220 sB5I5CNw:t 1595335887 -1 [duplicate, modified] [λ¨μ, man, , μμκΈ΄ λ¨μ = handsome man<br>κ°ν λ¨μ = s... HTSK Vocab
1589220255221 Hd>]fb:J&@ 1595335887 -1 [duplicate, modified] [μ¬μ, woman, , μμ μ¬μ = pretty girl<br>μλ¦λ€μ΄ μ¬μ =... HTSK Vocab
... ... ... ... ... ... ...
1597361136294 Or~GRLb0h4 1597361133 -1 [] [μμ, laughter, a smile, , , ] HTSK Usages
1597361136295 P~hT^`}adj 1597361133 -1 [] [μκ² ν΄ μ£Όλ€, to make somebody laugh, , , ] HTSK Usages
1597361136296 xVwInN0/GS 1597361133 -1 [] [건κ°μ μ’λ€, healthy, , , ] HTSK Usages
1597361136297 O[y=E>>ogO 1597361133 -1 [] [κ±΄κ° κ²μ§, health check up, , , ] HTSK Usages
1597361136298 FYBq5<JyXC 1597361133 -1 [] [νμ¬κΉμ§λ, until now, , , ] HTSK Usages
[5330 rows x 6 columns]
>>> get_info(col.db)
col.notes
now works like a charm.Your earlier testing recommendations don't survive, but maybe you know that already.
>>> get_info(col.db) {1: {'crt': 1597392000, 'mod': 1598225343106, 'scm': 1598220616405, 'ver': 15, 'dty': 0, 'usn': 0, 'ls': 0, 'conf': '', 'models': '', 'decks': '', 'dconf': '', 'tags': ''}}
So I have to subscript that get_info call with [1]["models"] instead of just "models", and it ends up empty.
But col.notes and col.cards have integers in nmod and cmod, and col.notes has strings in nmodel that track to my note types, so there are models floating around in there. Maybe that means everything's working as expected.
Right, you now need to use ankipandas.raw.get_model_info
to retrieve the information.
Perhaps get_info
should be renamed to get_collection_info
as it now only includes the kind of "global" information. This is a change that was introduced in anki.
I'd say this looks like it's working, so I'll close this issue, but feel free to write more or re-open if anything should arise :)
@allcontributors please add @brownbat for bug
@klieret
I've put up a pull request to add @brownbat! :tada:
hmm that didn't work as intended. @allcontributors please add @brownbat for bug
@klieret
I've put up a pull request to add @brownbat! :tada:
Was just kicking the tires, col.revs and col.cards worked as expected, but ran into an issue when calling col.notes:
(with
col = ankipandas.Collection()
, which it seemed to find fine.)