# csvreader and csvstyle with siunitx: “Paragraph ended before NC@rewrite@S was complete”

I'm trying to define a csvstyle that I can use for multiple tables using csvreader, however I'm running into errors trying to separately format 'S' columns. Each table has the same column names and data types; they are simply results from differing experimental scenarios.

For the following data:

Dataset1.csv

Name,ValueA,ValueB,ValueC
John,623.95, 8.954847, 0.000772
Anna,602.40,8.93469, 0.000772
Jacob,1987.17,8.796296, 0.000926


This is the furthest I can get:

\documentclass{article}
\usepackage{csvsimple}
\usepackage{filecontents}
\usepackage{siunitx}

\begin{filecontents*}{Dataset1.csv}
Name,ValueA,ValueB,ValueC
John,623.95, 8.954847, 0.000772
Anna,602.40,8.93469, 0.000772
Jacob,1987.17,8.796296, 0.000926
\end{filecontents*}

\begin{document}
\csvstyle{MyStyle}{
tabular=|c|S|S|S|,
table head =\hline {Name} & {ValueA} & {ValueB} & {ValueC} \\\hline,
table foot=\hline
}

\csvreader[MyStyle]{Dataset1.csv}{}{\Name & \ValueA & \ValueB & \ValueC}
\end{document}
%\csvreader[MyStyle]{Dataset2.csv}{}{\Name & \ValueA & \ValueB & \ValueC}
\end{document}


Any attempt to change an S into an S[table-format=4.2] (and remove it from before reading) so that I can column-by-column adjust the number of decimal places yields a

Paragraph ended before \\NC@rewrite@S was complete. ...sv}{}{\Name & \ValueA & \ValueB & \ValueC}


error. Any assistance would be greatly appreciated.

\newcolumntype{H}{S[table-format=4.2]}

Then you can use H instead of S, when desired and remove the format command from your before reading macro.