3

Trying to parse table with russian symbols. Example csv file:

Название, Автор, Год
Бесы, Достоевский, 1871

Can't create a table from this file with any command: \csvloop, \csvautotabular{table.csv}, \csvautobooktabular{table.csv}. While if everything is in English — works perfect.
File table.csv UTF-8 encoded, document uses \usepackage[utf8]{inputenc}, \usepackage[english,russian]{babel}.

These are the errors:

! Package csvsimple Error: File 'table.csv' starts with an empty line!.
! Missing \endcsname inserted.
! Extra \endcsname.
! File ended while scanning use of \pgfkeys@temp

Can't find anything in documentation or elsewhere in the Tex forums on this problem.

Example .tex file:

\documentclass[a4paper,11pt]{ncc}
\usepackage[english,russian]{babel}
\usepackage[utf8]{inputenc}
\usepackage{csvsimple}
\begin{document}
\csvautotabular{table.csv}
\end{document}
  • Welcome! Can you please add a small LaTeX file that shows the issue, from \documentclass to \end{document}? – egreg Nov 27 '18 at 17:30
  • @egreg Sure. I just did. – Grigory Shepelev Nov 27 '18 at 17:32
2

There are two orders of problems.

  1. The first row is also used to give symbolic names to the columns, but Cyrillic characters cannot appear in command names. Possibly this can be solved by options not to interpret the first line.

  2. Cyrillic characters seem to thoroughly confuse csvsimple; you'd need to brace each entry.

My suggestion is to use XeLaTeX.

\begin{filecontents*}{\jobname.csv}
Название, Автор, Год
Бесы, Достоевский, 1871
\end{filecontents*}

\documentclass[a4paper,11pt]{ncc}
\usepackage[english,russian]{babel}
\usepackage{fontspec}
\usepackage{csvsimple}

\setmainfont{CMU Serif}

\begin{document}
\csvautotabular{\jobname.csv}
\end{document}

I used filecontents and a different name for the CSV file just not to clobber my files and to make the example self-contained.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.