Is there a hard limit when importing?

Hi, I'm struggling on importing a csv file I generated from a deck I already have just to add a new field and update it to the deck. I have done this several times without an issue. But this time the file to import it’s relatively large. How I try to import Anki gets stuck in “importing...” window. I have checked and the cpu load stays constant at 0% and having plenty of free RAM memory. So it’s not hardware bottleneck.

Let me explain the reason I’m trying to import this:

I have about 6000+ Japanese kanji notes with a filed linking to a svg file, which many of them weights 3-7kB. But since the sd card where I storage the media has a bytes per sector too low it ends up taking so much space and fills the whole sd card, it take so much space inefficiently.

So I thought that since many small files is not good for fat32 I tried to embed the svg into a field. I converted the svg into base64 string into the field and then with the help of css can show it. SO, no dependencies whatsoever and faster to transfer on the cell phone because one large file is preferible that many small files.

This increases the size of the deck, ergo anki database, but theorically just in 18MB at maximum. Not a big deal. It is already at 110MB (uncompressed).

My front template contains this:
<object type="image/svg+xml" data = "data:image/svg+xml;base64,{{uri}}">

And my uri field is like this:

This works. I have done it manually in one card to make sure it is feasible. The problem is the bulk import with the URI fields that Anki seems unable to do. It is just the bulk import of 6000+ lines with a string of data URI of 3k-7k and is when it never ends importing and doesn’t seems to be using computer resources at all.

Thank you for your amazing support.

  1. 1 Posted by Guillem Palau-S... on 15 Aug, 2014 09:33 PM

    Guillem Palau-Salvà (contributor user)'s Avatar


    I changed the way I was importing the data.
    I found out that several fields of base64 are long because they are from png that represents a kanji (when the picture is just a part of a kanji, where is not coded by itself in unicode) and is larger than the default limit of python and I get this message:

    Importing complete.
    Aborted: field larger than field limit (131072)

    I've searched on the net and I found that this limit can be incremented with the following line of code:


    My question is, where and which file do I have to modify to see the changes.

  2. 2 Posted by Soren Bjornstad on 15 Aug, 2014 10:15 PM

    Soren Bjornstad's Avatar

    Hi guillem,

    The issue is caused by the limit on line length, as you appear to have figured out now. The reason we have the limit is because extremely large fields like this can cause slow performance along with the increased collection size. We would encourage you not to try to get around it, but since it appears that your other option isn't great either, it might be worth a try. The right place to insert it would be at the top of anki/importing/ (I haven't tested an abnormally large import with the change, but I have confirmed it didn't cause an error when importing a file). If it's more convenient to do so, writing an add-on that imports anki.importing.csvfile and then sets it from there should be equivalent.

  3. 3 Posted by Guillem Palau-S... on 16 Aug, 2014 09:03 AM

    Guillem Palau-Salvà (contributor user)'s Avatar

    Awesome !

    I just did my first add-on :-) Its just 2 lines, but does what I need.
    When I build up enough programming skills I would be delighted to contribute to the project.

  4. 4 Posted by Soren Bjornstad on 16 Aug, 2014 01:48 PM

    Soren Bjornstad's Avatar

    Glad you found a solution.

  5. Soren Bjornstad closed this discussion on 16 Aug, 2014 01:48 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac