Import File gets an error on a certain line of CSV file created by download from Google Sheet

Paul Czyzewski's Avatar

Paul Czyzewski

15 May, 2020 03:42 AM

I'm running Version 2.1.15 (442df9d6)
Qt 5.12.1 PyQt 5.11.3 on Mac OS High Sierra.

I have a simple deck (cards have front + hint + back). I have a google sheets doc with four columns, Front, Back, Hint, and a fourth column which isn't part of the card.
    I do File:Dlownload from the Google Sheet and select CSV as the output.
   Originailly there were about 100 cards in the CSV file, I deleted most of them but preserved the card which causes the error.
   I do Import File, telling Anki to use the first three fields and to ignore the fourth field.

Here is the output

Importing complete.
'Ways to use Regex module funcs vs compiled-pattern-object methods (and attributes) The module defines several functions, constants, and an exception. Some of the functions are simplified versions of the full featured methods for compiled regular expressions. Most non-trivial applications always use the compiled form.

RE and REGEX have top-level functions called match(), search(), findall(), sub(), and so forth.

PREFERRED: Better to compile to get a pattern object and then use its methods. EG.
pattern = r'
patObj = re.compile(pattern)
matchObj =

PEPs about parameter list,,, PEP 457 - Syntax For Positional-Only Parameters.' had 3 fields, expected 4

' had 1 fields, expected 4
0 notes added, 0 notes updated, 1 note unchanged.
First field matched: Files
  === END OF OUTPUT ====

The problem card is "Ways to do Reges", However, errors are reported two and three cards later.

I'll attach the csv file.

Any ideas? Possibly there's some invisible character causing an issue? Otherwise it seems like either Google Sheets download has a bug (if there's a formatting error in the CSV file) or Anki has a bug.

I can easily get around this but I thought I'd report it.

  1. Support Staff 1 Posted by Damien Elmes on 18 May, 2020 05:13 AM

    Damien Elmes's Avatar

    Looks like a bug - Anki is ignoring the lines that start with a #, even if they're in a quoted text block.

  2. 2 Posted by Paul Czyzewski on 18 May, 2020 06:10 AM

    Paul Czyzewski's Avatar

    Ah, your comment led me to me look for "#"s elsewhere in my input CSV and I see that a line in one field, which also begins with a "#", is simply missing from the Anki card.
       I guess my example file blew up the import because it was the *'last* line of a multi-line field. Thus, when Anki ignored it, it also didn't see the closing quotation mark which ended that row in the CSV, causing the exception.
       But, also, any line beginning with a "#" is just (silently) missing from the card it was going to be part of.

       Since you have you nailed down the specific cause, I can now easily work around it, until it gets fixed. :)

       BTW, I have no idea how many open bugs this product may have, or the resources available to fix them. Will a bug like this one (i.e., both the import-failure symptom and the silent-deletion symptom) likely be fixed relatively soon?


  3. Support Staff 3 Posted by Damien Elmes on 18 May, 2020 07:50 AM

    Damien Elmes's Avatar

    Hi Paul,

    Since I don't recall anyone else hitting this problem before, I'm afraid a fix will probably need to wait until I need to touch the CSV importing code for other reasons, so it may be a while.

  4. 4 Posted by Paul on 18 May, 2020 02:30 PM

    Paul's Avatar

    Hi Damien,
       Ok. That makes sense. Thanks for letting me know, and for finding what
    was breaking the import process.

Comments are closed, but you can start a new discussion.

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