For years, I’ve been importing into Anki from text files separated by semi-colons.
Today, the import function skipped about fifty cards from this one:
01282;"I'm happy because soon I'll get rid of you and I'll be able to go back to eating meat», my friend whose brother is a musician told me a week before I left the country to do the follow-up exams.;«Sono contenta perché presto mi libererò di te e potrò tornare a mangiare carne», mi disse la mia amica dal fratello musicista una settimana prima che lasciassi il paese per fare gli esami di controllo.<br><br><i>dei musicisti</i>;
You may note that I had a mismatch of quotation marks in field two: it opens with " and closes with ».
As a result, for note 01282, Anki imported all notes up to 01331’s field 3 into field 3 (01331 also has a ":
01331;At a time when social rights are dwindling for all and the supreme leader sharpens people's fears, "Become Outraged" is a warning to live constructively.<br><br>(two options for <i>warning</i>);In un'epoca nella quale i diritti sociali si assottigliano per tutti e il capo supremo acuisce le paure della gente, «Indignatevi» è un monito per vivere costruttivamente.<br><br>/<i>un avvertimento, un avviso, un'avvertenza</i><br><i>assottigliare</i>: to thin | to sharpen, along with <i>affilare</i><br><i>acuire</i>: HOE → (i) <i>Rendere acuto e penetrante, spec. fig.: acuire. la vista, l'ingegno, il desiderio, la passione SIN. aguzzare,</i> (ii) <i>acuìrsi. Farsi più acuto: si acuiva in lui l'ansia dell'attesa SIN. acutizzarsi</i><br>/<i>accentuare, esacerbare, aggravare, peggiorare</i><br><i>un monito</i>: HOE → <i>Ammonimento severo, avvertimento solenne: che queste mie parole ti siano di m.</i>;
Why should Anki care whether quotes within notes are well-formed or not? To me that makes no sense, there are situations where one may legitimately use only one of a pair of quotes. Only separators should matter. But maybe I’m missing something.
" is used to escape special characters like field and line separators in CSV. If you misplace quotation marks, it’s unclear where fields and lines start or end and different CSV libraries will interpret the invalid file inconsistently.
When you include quotes inside CSV files, you’re telling the CSV parser to ignore the “natural boundaries” and include the field separators as part of the field until the quotes are closed. If you try import the following small sample into either Excel, LibreOffice, or even old versions of Anki, you’ll see that you end up with only two rows there as well, instead of the four that you seem to be expecting.
Your complaint seems to be that Anki should have done what you intended, instead of what you told it to do. I’m afraid that’s a rather hard problem.
Escape the multi-lines by placing the contents of the field in quotation marks:
hello; "this is
a two line answer"
two; this is a one line one
Because quotes are used to mark where a field begins and ends, if you wish to include them inside your field, you need to replace a single doublequote with two doublequotes to “escape” them from the regular handling, like so:
field one;"field two with ""escaped quotes"" inside it"
When you use a spreadsheet program like Libreoffice to create the CSV file for you, it will automatically take care of escaping double quotes.
Hi Rumo, in your understanding, how should I escape the following quote within field two so it displays correctly?
01282;"I'm happy because soon I'll get rid of you and I'll be able to go back to eating meat", my friend whose brother is a musician told me a week before I left the country to do the follow-up tests.;
I tried this:
01282;""I'm happy because soon I'll get rid of you and I'll be able to go back to eating meat"", my friend whose brother is a musician told me a week before I left the country to do the follow-up tests.;
The first quote does not appear when the note is displayed in Anki. The second quote appears doubled.
Of course it might be easier to switch to curlies.
There are two steps to include literal double quotes:
Wrap the field in double quotes.
Double all double quotes inside that field.
In your example:
01282;"""I'm happy because soon I'll get rid of you and I'll be able to go back to eating meat"", my friend whose brother is a musician told me a week before I left the country to do the follow-up tests.";