field limit

chen li's Avatar

chen li

17 May, 2016 01:28 AM

Hi all,

Is it possible to set the field limit for anki? I have a CSV file that contains several records which have a field size >130712.

Thanks,

  1. Support Staff 1 Posted by Damien Elmes on 17 May, 2016 11:30 AM

    Damien Elmes's Avatar

    Anki wasn't designed to handle such large fields ,and you will likely experience slow performance if each note's fields approach that size. There's no way to lift the limit inside Anki, but if you're determined it would be possible in an add-on.

  2. 2 Posted by chen li on 17 May, 2016 03:37 PM

    chen li's Avatar

    Do you know which add-on?
    Thanks.

  3. 3 Posted by Soren Bjornstad on 17 May, 2016 07:55 PM

    Soren Bjornstad's Avatar

    No such add-on exists currently that I know of -- it was a suggestion that you or someone else could write one.

  4. 4 Posted by Guillem Palau-S... on 23 May, 2016 11:31 AM

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

    Hi Li iChen, I came across the same issue two years ago. Here's the link

    you can make a 4-liner addon like this:

    # -*- coding: utf-8 -*-
    import csv
    import anki.importing.csvfile
    
    csv.field_size_limit(2*1024*1024)
    

    This code sets the new limit to 2MB. You can chage it yo whatever you want. Use it with caution.
    I have shared this addon. The number is 389776307

  5. 5 Posted by Soren Bjornstad on 23 May, 2016 12:34 PM

    Soren Bjornstad's Avatar

    Thanks guillem!

  6. 6 Posted by chen li on 24 May, 2016 05:04 PM

    chen li's Avatar

    Thank you. I just copy your codes, save it as a size.py file, put it into addons folder in anki.

    It works perfectly for me.

    Once again, thank you very much.

  7. 7 Posted by chen li on 28 May, 2016 01:33 AM

    chen li's Avatar

    Hi Guillem,

    Is it possible to change the default field delimiter into a custom one like '|' by adding a new line code to you addons?

    I check Py document about reading CSV file(https://docs.python.org/2/library/csv.html):
    ====================
    import csv
    with open('eggs.csv', 'wb') as csvfile:
        spamwriter = csv.writer(csvfile, delimiter=' ',
                                quotechar='|', quoting=csv.QUOTE_MINIMAL)
        spamwriter.writerow(['Spam'] * 5 + ['Baked Beans'])
        spamwriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])
    ====================

    but I cannot find a method to change the delimiter of fields.

    I wonder if you could please give me a clue.

    Thanks,

  8. 8 Posted by Soren Bjornstad on 28 May, 2016 02:38 PM

    Soren Bjornstad's Avatar

    There's an option to select the delimiter in Anki's import dialog -- there is no need to do anything in an add-on.

  9. 9 Posted by chen li on 28 May, 2016 03:39 PM

    chen li's Avatar

    I know there is an Anki's import dialog. But I have to import many CSV files with delimiter '|', instead of the default one used by Anki. So it will be nice if I can reset the default delimiter to the one used in my parse CSV files by adding 1 or 2 line code to an addons.

          From: Soren Bjornstad <[email blocked]>
     To: [email blocked]
     Sent: Saturday, May 28, 2016 10:38 AM
     Subject: Re: field limit [Anki (Computer Version) #18277]
       
     #yiv3161586611 pre {width:92%;margin:10px 2%;padding:5px 2%;background:#efefef;border:1px solid #d6d6d6;}#yiv3161586611 blockquote {margin-left:0;padding-left:1em;border-left:5px solid #ccc;}

  10. 10 Posted by Ankitest on 16 Jun, 2016 07:13 PM

    Ankitest's Avatar

    But I have to import many CSV files with delimiter '|', instead of the default one used by Anki.

    As an idea:
    you can make a batch replace '|' with tab char in text editor before import.

  11. 11 Posted by chen li on 16 Jun, 2016 10:37 PM

    chen li's Avatar

    It is a good idea. I will give it try in the future.

          From: Anki Testing <[email blocked]>
     To: [email blocked]
     Sent: Thursday, June 16, 2016 3:13 PM
     Subject: Re: field limit [Anki (Computer Version) #18277]
       
     #yiv6753657746 pre {width:92%;margin:10px 2%;padding:5px 2%;background:#efefef;border:1px solid #d6d6d6;}#yiv6753657746 blockquote {margin-left:0;padding-left:1em;border-left:5px solid #ccc;}

  12. 12 Posted by Soren Bjornstad on 10 Jul, 2016 04:37 PM

    Soren Bjornstad's Avatar

    Maybe I'm still not understanding the problem -- when you import a file into Anki, there is a button you can push where you tell Anki that it should use the delimiter |.

    Or are you saying you'd like to change the delimiter used when exporting, rather than importing?

  13. 13 Posted by Ankitest on 10 Jul, 2016 04:48 PM

    Ankitest's Avatar

    The problem arises when we have to import 30 files in a row:
    then we have thirty times to press the button and specify the same delimiter.

  14. 14 Posted by chen li on 11 Jul, 2016 12:05 AM

    chen li's Avatar

    Yes. This is what happens to me: I have to import many files--about 100 files for my project.
    So it will be nice if I can change the default separator to what I prefer---kind of set preference once from Anki  and it will apply it forward for all subsequent imported files.
    Since I don't know Python language, it will be nice someone who is an expert on Python writes an addons to do the job.

          From: Dmitry Mikheev <[email blocked]>
     To: [email blocked]
     Sent: Sunday, July 10, 2016 12:48 PM
     Subject: Re: field limit [Anki (Computer Version) #18277]
       
    #yiv0916348050 pre {width:92%;margin:10px 2%;padding:5px 2%;background:#efefef;border:1px solid #d6d6d6;}#yiv0916348050 blockquote {margin-left:0;padding-left:1em;border-left:5px solid #ccc;}

  15. Support Staff 15 Posted by Damien Elmes on 11 Jul, 2016 01:39 AM

    Damien Elmes's Avatar

    I'll look at supporting pipes out of the box in the future - in the mean time using a tab or : colon character should let Anki autodetect it, or you could join all your files together before importing them in one go.

  16. 16 Posted by Soren Bjornstad on 16 Aug, 2016 12:31 AM

    Soren Bjornstad's Avatar

    This ticket has been automatically closed due to inactivity. If you are still having issues or need to continue this discussion, please feel free to reply.

    If you are not the original poster but are experiencing a similar issue, please create a new thread and include a link to this one if appropriate.

  17. Soren Bjornstad closed this discussion on 16 Aug, 2016 12:31 AM.

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

Keyboard shortcuts

Generic

? 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