# Parsing input for table automatically generated from csv file

I have a .csv file which looks like:

{one},{two},{three}
11/07/2014,14:49:54,(100,100)
2,2,2


I have some code which creates a table from the .csv file.

 \documentclass{article}

\usepackage{booktabs}

\usepackage{siunitx}

\usepackage{pgfplotstable}

% Setup siunitx:
\sisetup{
round-mode          = places, % Rounds numbers
round-precision     = 2, % to 2 places
}
\begin{table}[h!]
\begin{center}
\caption{Autogenerated table from .csv file.}
\label{table1}
\pgfplotstabletypeset[
multicolumn names, % allows to have multicolumn names
col sep=comma, % the seperator in our .csv file
display columns/0/.style={
column name=$Value 1$, % name of first column
column type={S},string type},  % use siunitx for formatting
display columns/1/.style={
column name=$Value 2$,
column type={S},string type},
display columns/1/.style={
column name=$Value 3$,
column type={S},string type},
before row={\toprule}, % have a rule at top
after row={
\si{\ampere} & \si{\volt} & \si{\tesla} \\ % the units seperated by &
\midrule} % rule under units
},
every last row/.style={after row=\bottomrule}, % rule at bottom
]{/path/to/file/table.csv} % filename/path to file
\end{center}
\end{table}

\end{document}


Taken from this tutorial

However, I get errors for every csv cell where I have either a "," or a ":".

Package PGF Math Error: Could not parse input '(100,100)'
|75 error| Package PGF Math Error: Could not parse input '00:04:00'


I've tried the usual suspects by wrapping the cells in "" or {} but to no avail.

• Your MWE is missing a \begin{document}. Is column type={S} the right thing to be using? As I understand this expects a single number (to align on decimal point) which is definitely not true in this example. From what I can see it is the (100,100) entry alone causing trouble, unfortunately I agree the usual escapes don't work, {14:49:54} seems to fix the erros on the second entry in that line though. – Dai Bowen Nov 19 '16 at 19:38

I would have used comment to point things out, but I cannot yet; though this is no complete answer yet…

When I minimize your example and make it compile (document does not begin anywhere yet), I get to

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{pgfplotstable} \pgfplotsset{compat=1.14}
\usepackage{filecontents}

\begin{filecontents}{table.csv}
{one},{two},{three}
11/07/2014,14:49:54,(100,100)
2,2,2
\end{filecontents}

\begin{document}
% Setup siunitx:
\sisetup{round-mode = places, round-precision = 2 }
multicolumn names, % allows to have multicolumn names
col sep=comma, % the seperator in our .csv file
display columns/0/.style={
column name=$Value 1$, % name of first column
column type={S},string type},
display columns/1/.style={
column name=$Value 2$,
column type={S},string type},
display columns/1/.style={
column name=$Value 3$,
column type={S},string type},
before row={\toprule}, % have a rule at top
after row={
\si{\ampere} & \si{\volt} & \si{\tesla} \\
\midrule} % rule under units
},
every last row/.style={after row=\bottomrule},
]{table.csv} …
\end{document}


It then results in the helpful error message:

Package pgfplots Error: Table 'table.csv' appears to have too many columns in line 5: Ignoring '100)'. PGFPlots found that the number of columns is larger t han the previously determined number of columns. Please verify that every cell entry is separated correctly (use braces {} if necessary. Also veri fy that column names are plain ASCII.). This error is not critical.

Next I suggest

• replace the coordinate delimiter with sth. else than comma (which is in use for the csv) or
• replace the comma for cell separation with e.g. semicolon

Also consider next time:

• create minimal working example (often referred to as MWE)
• and make it in a single file (see filecontents)

because the pros (that might be able to help you instantly) do not waste their time on doing that for you.