0

I'm using csvsimple to turn a CSV file into a table. I would like to embed the content of the CSV file into the LaTeX source file itself. Is this possible?

\documentclass{article}
\usepackage{csvsimple}
\begin{document}
\csvautotabular{csv.csv}
\end{document}

where csv.csv contains, for example,

1,2,3
4,5,6

I'm thinking about doing something like:

\documentclass{article}
\usepackage{csvsimple}
\begin{document}
\csvautotabular{
1,2,3
4,5,6
}
\end{document}
1

According to Thomas F. Sturm's comment:

\documentclass{article}
\usepackage{csvsimple}
\usepackage{filecontents}
\begin{document}
\begin{filecontents*}{csv.csv}
1,2,3
4,5,6
\end{filecontents*}
\csvautotabular{csv.csv}
\end{document}
  • \usepackage{filecontents} is needed to be able to declare the filecontents environment outside of the preamble.
  • The starred filecontents* is needed to disregard the return character after \begin{filecontents*}{csv.csv}.

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.