File Headers won't work if .csv was created with LibreOffice Calc

This is about File Headers.

Expected Behavior

When importing a .csv, while using file headers to denote e.g. notetype, Anki should recognize the file header and apply it accordingly and properly.

Also see the Workarounds chapter below.

Actual Behavior

Anki doesn’t recognize the file headers if they have been created via LibreOffice Calc, or interprets them incorrectly.

Steps to Reproduce

  1. Create a sample .csv in LibreOffice Calc and save it with field delimiter ,, String delimiter ".
  2. Click Import in Anki.
  3. See that the notetype and deck are incorrect (but the field separator is correct):

Additional Info

#1

Anki asks to create a new Pineapple,, deck. That is due to the additional fields (Comma separated). Anki doesn’t recognize the actual Pineapple deck:

#2

The generated .csv looks like this:

#separator:Comma,,
#notetype:Cloze,,
#deck:Pineapple,,
Front,Back,Tags
Hello,World,Tags::Sub_Tags

#3

If the .csv was created with the Quote all fields option checked in LibreOffice, then you get the following generated file:

"#separator:Comma",,
"#notetype:Cloze",,
"#deck:Pineapple",,
"Front","Back","Tags"
"Hello","World","Tags::Sub_Tags"

In this case, the workaround provided below only works, if you remove the " from the lines starting with #. Also, with this quote option turned on, Anki no longer guesses the separator correctly; it falls back to Colon.

Workarounds

One could manually modify the .csv outside of LibreOffice like this:

#separator:Comma,,
#notetype:Cloze
#deck:Pineapple
Front,Back,Tags
Hello,World,Tags::Sub_Tags

Though this isn’t user friendly.

Affected versions

At least the following:

Current Stable
Anki 25.07.5 (7172b2d2) (ao)
Python 3.13.5 Qt 6.9.1 PyQt 6.9.1
Platform: Linux-6.12.38+deb13-amd64-x86_64-with-glibc2.41

Current Release Candidate
Anki 25.09rc1 (5c4d2e87) (ao)
Python 3.13.5 Qt 6.9.1 PyQt 6.9.1
Platform: Linux-6.12.19-amd64-x86_64-with-glibc2.41

Related

https://github.com/ankitects/anki/issues/3853

@llama

Can we just apply your solution to the following two as well?

That should solve it as far as I understand*.


* Except for the case where the separator is Colon, as LO Calc will auto quote the metadata field in this case (because it contains a Colon)

This looks identical to Import of CSV not reading all File Headers in v. 25.07.01 - Anki / Development - Anki Forums, with the solution proposed by dae there likely to be the one used going forwards

1 Like

Except that that user had a working deck header, which doesn’t work for me either.

No idea how I missed that report though, it indeed is very similar.

My understanding is that he did not. Why he left that unclarified is :man_shrugging:

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