Read a csv file row by row and create a table

csvtables

I have a problem reading my rows from the .csv database. Separated by commas every key.
So, here is my .csv:

id,term,description
1,"system","name"
2,"syst2","description system"
3,"syst3","no name"

And here is my table where I put it (I made it MVE):

\documentclass{article}
%\documentclass{ICD}
\usepackage[T2A,T1]{fontenc}
%\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{multicol}
\usepackage[russian,english]{babel}
%\usepackage[russian]{babel}
\usepackage{multirow}   %для таблиц со слиянием столбцов и строк
\usepackage{amsthm}
\usepackage{array}      %для таблиц с заданной шириной столбца
\usepackage{float}
\usepackage[table]{xcolor}
\usepackage{filecontents}
\usepackage{hyperref} 
\usepackage{datatool} %для работы с базами данных

\begin{document}
\newpage
\DTLloaddb{myDB}{terms.csv} %работа с базой данных
 \begin{DTLenvforeach}{myDB}{\id=id,\Ter=term,\desc=description}
 
 \vspace{\fill}
 \end{DTLenvforeach}

\section{Термины, определения и сокращения }
\begin{table}[!ht]
    \centering
    \begin{tabular}{|c|c|c|}
         no& Термин/сокращение & Описание, расшифровка  \\
         \hline
         \id &  \emph{\T} &  \emph{\TA} \\
         \hline
        % 2 &  \emph{\TB} &  \emph{\TC} \\
        \id&\emph{\Ter} & \emph{\desc}\\
         \hline
        % 3 & \emph{\TD} & \emph{\TE} \\
          2&\emph{\Ter} & \emph{\desc}\\
         \hline
         4 & \emph{\TF} & \emph{\TG}  \\
         \hline
         5 & \emph{\Th} & \emph{\TI}\\
         \hline
    \end{tabular}
    %\caption{Caption}
    \label{tab:my_label}
\end{table}

\end{document}


\endinput

Best Answer

Depends on the complexity of your CSV file. For simple csv files like in your question, using package csvsimple-l3 would be the simplest way to go. See the following example.

\documentclass[border=1cm]{standalone}
\usepackage{csvsimple-l3}
\begin{filecontents*}[overwrite]{sample.csv}
id,term,description
1,``system'',``name''
2,``syst2'',``description system''
3,``syst3'',``no name''
\end{filecontents*}

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

It generates:

1


Note that I have changed the normal quotations, i.e., Here is some "text". with the LaTeX-friendly quotations, i.e., Here is some ``text''.

Related Question