Three Issues with Export function

I’m having three issues with the Export function that make the process of Exporting / Modifying / Importing very prone to errors (a process needed for operations too complex for the Find/Replace function in the browser).

  1. Cannot choose delimiter
    Export forces the TAB delimiter. Not convenient, forces a search/replace. IMO all delimiters which are allowed in headers should also be allowed in export: Comma , Semicolon , Tab , Space , Pipe , Colon
    See Text Files - Anki Manual

  2. Export escapes double quotes, making it impossible to import again
    For instance,

<img src="AFDOT-foundation.jpg">

becomes

"<img src=""AFDOT-foundation.jpg"">"

This leads to import errors
I really don’t see a reason to escape double quotes in particular…
This makes the re-import very prone to errors.

  1. Deck and Notetype headers are missing
    I appreciate that the exported file contains the following headers:
#separator:
#html:
#tags column:

However, tags and deck are missing, making re-import error-prone.
When the checkbox is checked, they are pre-prepended to each note, which is rather ugly, but no header is generated.
I recommend adding these two headers:

#deck:
#notetype:

Thank you for your attention!

1 Like

Since this is a suggestion, can you explain how this “forces a search/replace” for your use case? It sounds like there is some reason you can’t leave the delimiter as-is in your file, and knowing that reason will help the devs understand how a change would help.

The page of the manual you linked to explains why double quotes within a field need to be escaped. You don’t say what sort of import errors you’re getting. As long as your file manipulations don’t interfere with the relationship between double quotes and escaped double quotes, your file should import just fine.

Yes, you have to check those boxes to include that information in an export. But you don’t say what errors this is causing for you on re-import.

If your only concern is that using #deck column and #notetype column doesn’t look as good in your CSV file, I think it’s unlikely that will change. Using the column-type headers instead of overall file headers allows much more flexibility for users, and it’s obviously necessary when all of the exported notes are not of the same note type, or their cards are in different decks.

If you don’t need that flexibility and want the file to look different, it seems like you could reduce those to overall file headers for yourself with a few copy-pastes and deleting those columns.

3 Likes

Thank you for your reply and sharing your thoughts.

  1. Regarding the tabs, I am forced to do a search-replace because tab-delimited files are hard to edit in most text editors. Tabs typically don’t appear with a consistent width, so it’s often hard to know whether a space is a space or a tab. I use EditPad Pro which will actually let me visualize tabs. Still, it’s visually less pleasing and harder to work with than working with semicolons.

At the end of the day, all I’m saying is that if Anki allows Semicolon and a few others in the headers, why not make it easy for users and also allow those while exporting.

  1. Escaped double quotes create problems when I edit the file and add other segments with double quotes. To avoid these and other problems, at the moment, after exporting I let Python massage the file so I can work with it again.

For my present export situation I fail to see the point of exporting with escaped double quotes, as importing my regular file with unescaped double quotes works fine. But I’m sure that you’re right and it makes sense for certain cases that just aren’t in my files, such as an entire field within double quotes. So maybe I should try switching to single quotes within my files, especially for things such as href=" and src="

  1. Regarding the #deck: and #notetype: headers, I read what you said.
    But when exporting a single deck it would be such a simple thing to add, really the cost is zero, and it’s much cleaner than the columns.
    As I said for my current task I switched to post-processing with Python, but the next time around it will be a problem again, and having to paste these column names just isn’t an elegant solution.

Actually, I just tried that, they are correctly replaced in the text file, but…
Anki converts them back to double quotes upon importing!

SRC_HREF = re.compile(r'''(?P<src>(?:src|href)=)"(?P<link>[^"]+)"''')
exported = SRC_HREF.sub(r"\g<src>'\g<link>'", exported)

Not the first time Anki’s import function messes with the input, I recall when it started sorting tags a few years ago, that gave me some grief.

Thanks for clarifying those things!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.