2

I am exporting from Origin and get a Data.csv like this:

Short_Name1; Short_Name2
Long_Name1;  Long_Name2
Unit1;       Unit2
Comment1;    Comment2
1,1;         2,0
3,5;         4,3

When I try to print that with pgfplotstable, I need to do something like:

%!TEX TS-program = lualatex
\documentclass[]{scrartcl}


%\usepackage{pgfplots}
\usepackage{
            pgfplotstable,
            booktabs,
            array,
            colortbl,
            }

\pgfplotsset{compat=1.12}

\begin{document}

\pgfplotstabletypeset[
    col sep=semicolon,
    read comma as period,
    fixed,
    zerofill,
%   string type,
    precision=2,
    ignore chars={\_},
   %dec sep align, %prints both strings in first column, aligned at the comma
%
    every head row/.style={
        before row={\toprule },
       after row={\midrule },
        },
    every last row/.style={
        after row=\bottomrule
        },
    every even row/.style={
        before row={\rowcolor[gray]{0.985}}}, %also a problem
%
    %every row 0/.style={string type}, %does not work
%    \directlua{    for i = 0, 2 do  %does also not work
%               for j= 0,1 do 
%                   tex.sprint( "every row ",i," column ",j,"\noexpand/.style={string type}, " ) 
%               end
%           end }
    every row 0 column 0/.style={string type},
    every row 0 column 1/.style={string type},
    every row 1 column 0/.style={string type},
    every row 1 column 1/.style={string type},
    every row 2 column 0/.style={string type},
    every row 2 column 1/.style={string type},
%
    every row 2/.style={
        after row={\midrule },
        },
]
    {Data.csv} 

%looks like it should as workaround, but is not processed properly
\directlua{     for i = 0, 2 do
            for j= 0,1 do 
                tex.sprint( "every row ",i," column ",j,"\noexpand/.style={string type}, " ) 
            end
        end }



\end{document}

Is there any more convenient way of doing that?

I would also be happy if it was possible to get

Long_Name1 [Unit1] 

as one header line and ignore the two remaining string lines. It is no problem to export just two of them via Origin.

EDIT: I already tried every row no 0/.style={string type},, it produces an error.

header=false will result in columns named 0 1 2 3 and so it would need to give each column name as

columns/<index>/.style={
        string type,
        column type=l,
        column name={Long_Name [Unit]}
        },

EDIT2: header=false-"Problem" is already solved here

So I will try to do the processing

Long_Name1;  Long_Name2
Unit1;       Unit2
1,1;         2,0
3,5;         4,3

to

Long_Name1 [\si{Unit1}];  Long_Name2 [\si{Unit2}]
1,1;         2,0
3,5;         4,3

with lua (python would be easier…) but not even my code to generate every row 0 column 0/.style={string type}, did work (and it definitely prints that line when it runs outside pgfplotstable).

I thought that must be some usual workflow and there has to be a simple solution already…

0 Answers0