How to keep line breaks when importing from Google Sheets to Anki (without using HTML)?

I’m trying to import data from Google Sheets into Anki and want to preserve line breaks as they are.

For example, in my spreadsheet I have:
Deoxy-ribo-nucleic acid.
Deoxyribonucleic acid.

These are in a single cell, separated by a line break.

But when I import the CSV into Anki, the content is displayed as a single line in the card, like this:
Deoxy-ribo-nucleic acid. Deoxyribonucleic acid.

I know that I can insert < /br > tags manually to force a line break in Anki, but I want to avoid injecting HTML into my spreadsheet.

Is there a way to preserve line breaks from a Google Sheet (or CSV export) into Anki without manually adding HTML?

Is there a workaround that doesn’t involve manually editing every cell with < /br>?

There are two ways to include newlines or the field separator in fields.

Text Files - Anki Manual. I haven’t personally had consistent luck with the non-HTML method – but admittedly, I haven’t tried very hard to get it to work.

If the above doesn’t work for you – as HTML goes, a <br> tag is fairly minor, and quite reliable. It is also exactly what would be created if you simply typed/pasted that text directly into Anki, since all fields are stored as HTML.

For an existing file, have you tried find-replace?

A tip: the correct tag is just <br> – no space, no closing-tag slash.

2 Likes

Thank you for your reply and help!

I tried wrapping the text in double quotes in my Google Sheet like this:

“Deoxy-ribo-nucleic acid.
Deoxyribonucleic acid.”

But after importing into Anki, it still shows up as a single line. Did I misunderstand the manual, or does Anki just not behave the way the manual says it should?

That’s what I mean about not having much luck with it. It depends on what the end-of-line character is in your spreadsheet, and that’s a bother to diagnose.

To check: have a look at the resultant CSV file in a normal text editor (e.g. Notepad, xEd). Can you see the broken line?

You should not personally need to place the double-quotation marks around the cell. The spreadsheet program should do that for you. Is there an option to configure Google Sheets on export (to CSV)?

Google Sheets only offers a few bits of functionality compared to more complete spreadsheet programs such as LibreOffice Calc and Microsoft Excel. Use LibreOffice Calc (free!); it produces a very honest CSV. i.e. true to the data and the standard.

Otherwise, just add the <br>; you only need to do a Search-and-Replace. I gave up the fight years ago; now I have HTML in most of my decks. It is just much easier to format, add colour, fonts, etc.

1 Like

Thank you for your advice!

I checked the raw text file, and it looks like the double quotation marks are still there.
45345345

I’m considering switching to using <br> and HTML formatting instead.

It just feels a bit unusual, since I’ve never used it that way before.

If you really are hesitant about using HTML, try installing LibreOffice and using it to create your CSV.

I use it several times a day to create or update my decks and it works fine, including texts in other languages (Latin, French, German, Hebrew, Greek, Arabic, Esperanto, …).

2 Likes

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