0

I tried to compil this code on overleaf and it did not work. Here is the link for my code.

On compiling this is the error being showed.

Missing \endcsname inserted.
<to be read again> 
                   \advance 
l.41     ]
          {n.csv} % filename/path to file 

I don't know what is going on. Typing out my table will take a long time.

2
  • Are you able to upload the csv file also? You need it to compile the document.
    – Sigur
    Jan 16, 2017 at 12:41
  • Yes I am able to upload it. I checked the csv file as well and it seems to be in the correct format.
    – Aswin S
    Jan 17, 2017 at 6:17

1 Answer 1

1

Effectively you can't use siunitx's S column for text. Change it and it works.

table output

\documentclass{article}
\usepackage{booktabs} % For \toprule, \midrule and \bottomrule
\usepackage{siunitx} % Formats the units and values
\usepackage{pgfplotstable} % Generates table from .csv
\pgfplotsset{compat=1.14}

% Setup siunitx:
\sisetup{
  round-mode          = places, % Rounds numbers
  round-precision     = 2, % to 2 places
}

\begin{filecontents}{n.csv}
Month,Solar Radiation(KWH/m2/day),Days Per Month,Output(KWh/month)
J,6.61,31,731.5287
February,6.92,28,691.7232
March,6.74,31,745.9158
April,5.9,30,631.89
May,5.48,31,606.4716
June,4.8,30,514.08
July,4.85,31,536.7495
August,5.05,31,558.8835
September,5.48,30,586.908
October,5.37,31,594.2979
November,5.4,30,578.34
December,6.09,31,673.9803
Yearly Totals,0,365,7450.7685
\end{filecontents}

\begin{document}

\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=$Month$, % name of first column
        column type={c},string type},  % use siunitx for formatting
      display columns/1/.style={
        column name=$Solar Radiation(KWHm2day)$,
        column type={S},string type},
        display columns/2/.style={
        column name=$Days Per Month$,
        column type={S},string type},
        display columns/3/.style={
        column name=$Output(KWhmonth)$,
        column type={S},string type},
      every head row/.style={
        before row={\toprule}, % have a rule at top
        after row={
            \si{\ampere} & \si{\volt}\\ % the units seperated by &
            \midrule % rule under units
        }
      },
        every last row/.style={after row=\bottomrule}, % rule at bottom
    ]{n.csv} % filename/path to file
  \end{center}
\end{table}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .