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!


            \read\file to\fileline % Reads a line of the file into \fileline
            % Do something with \fileline

          t1 & t2 & t3 \\
          y1 & val1 & val4 \\
          y2 & val2 & val3 \\

closed as unclear what you're asking by Symbol 1, Stefan Pinnow, Mico, user31729, egreg Apr 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:


The CSV file: 
Val <- read.csv("values.csv",header=T)
val <- Val$Values ## just to simplify the \Sexpr 
The \LaTeX\ table:\par
t1 & t2 & t3 \\\midrule
y1 & \Sexpr{val[1]} & \Sexpr{val[4]} \\
y2 & \Sexpr{val[2]} & \Sexpr{val[3]} \\

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