# Importing Data from CSV file to Latex Table [closed]

I am running WinEdt 9.0, MikTex 2.9 on windows 7 pro.

I am constructing a standard format PDF report and must follow that format (ie the table is in a particular format with colors and fonts etc etc). To be clear, the table layout is complex and predefined. All I have to do is add the data points.

The format requires large tables to be populated with float data points which are held in a CSV file on my PC.. There seems to be a number of ways of doing this but i am not sure which is the simplest. Ideally I would like to be able to "index into" myFile.txt eg x= load(myFile.txt), val1 = x(3,17); etc

How do I assign values from "myFile.txt" to my variables val1, val2, val3, val4?

my MWE is below. thank you!

            \documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{caption}
\usepackage{float}
\usepackage{xspace}
\usepackage{verbatim}
\usepackage{array}
\usepackage{multirow}
\usepackage{hhline}
\usepackage{ifthen}
%http://www.tug.org/texmf-dist/doc/latex/pgfplots/pgfplotstable.pdf

\openin\file=A:/myReports/latestResults/myFile.txt
\loop\unless\ifeof\file
% Do something with \fileline
\repeat
\closein\file

\begin{tabular}{|c|c|c|}
\hline
t1 & t2 & t3 \\
y1 & val1 & val4 \\
y2 & val2 & val3 \\
\hline
\end{tabular}
\end{document}


## closed as unclear what you're asking by Symbol 1, Stefan Pinnow, Mico, user31729, egregApr 1 '17 at 9:15

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• For further reference: LaTeX Community – Johannes_B Sep 24 '14 at 12:14
• Why is this tagged pgfplotstable if you don't load pgfplotstable? – darthbith Sep 24 '14 at 12:15
• Can you include some data rows from your CSV file to play with? @darthbith It's probably the question how to do in pgfplotstable. – percusse Sep 24 '14 at 12:31
• You could use pgfplotstable both to read in the data and to parse it (see \pgfplotstablegetelem). Since your tabular uses data from one row of your csv to fill more than one row of the tabular, \pgfplotstabltypeset will not be a good idea. – John Kormylo Sep 24 '14 at 16:24

An easy option is using knitr:

\documentclass[twocolumn]{article}
\usepackage{booktabs}
\parskip1em\parindent0pt
\begin{document}
The CSV file:
<<echo=F,comment=NA>>=