Writing to collection breaks synchronization and editing in Ankidroid
bughelp wanted
Hi,
First, thank you for this package! I wanted to edit notes in batch, I'm looking for different solutions, including developping my own Anki plugin, but Ankipandas looks like it could easily help me do my editing - this bug aside!
* **Goal** : I wanted to edit notes in batch to transform them from Cloze to basic cards. As the selected cards had the same question pattern, I could extract the fields from the cloze brackets using regex.
* **OS** : Windows 10
* **Steps taken** :
1. In a testing profile in Anki, create a new type of note, and convert the notes (is it possible to change the note type with Ankipandas ?). The main field in the resulting note still has the cloze brackets
2. In a notebook, run the following [code ](https://github.com/catherning/anki-collection-editing/blob/f4abf9bde2400626b77c872cf26f81d28564a183/ExCloze2Basic.ipynb) that will extract the wanted information from the main field and populate and replace a new field and the main field with it
```
notes = col.notes
selection = notes.loc[notes["nmodel"]=='Tour de France winners'].copy()
selection.fields_as_columns(inplace=True)
selection["nfld_Year"] = selection["nfld_Winner"].str.extract(r'(\d{4})')
selection["nfld_Winner"] = selection["nfld_Winner"].str.extract(r'{{c\d::(\D+)::who\?}}')
col.notes.update(selection.fields_as_list())
col.write(modify=True)
```
(For information, an example row value of selection["nfld_Winner"] is *{{c1::Cadel Evans::who?}} won the {{c2::2011::year}} Tour de France*. The extracted information are then *2011* and *Cadel Evans* respectively)
4. Export / import the collection from the testing to the main profile
5. The first time I ran into the issue, I did "Notes > Clear unused notes" and then "Tools > Check Database", because I had the flag issue #50. But skipping this step also led to the same issue
6. Synchronize the collection with Ankiweb
7. On mobile (Ankidroid), try to edit a note. When clicking on the check button to save, **the note has not saved the modification**
8. Synchronize the collection again
9. On Anki, synchronize the collection, and try editing a note. When synchronizing, I have the following popup

10. Checking the database again doesn't work, I **can't synchronize the collection anymore** and the popup keeps appearing. Forcing the sync push to Ankiweb works, I get the update in Ankidroid then, but I still can't edit notes in Ankidroid
I hope this is clear enough!
13 条评论