Ich habe versucht, Beispiele aus5.4 Tabellen mit Zahlenformatierungaus csvsimple
dem Paket, aber ohne Erfolg.
Jede Zeile in meinemcsv
Datei hat 20 Felder,alle von ihnenhat ein Format wie x.xxxxxx
. Hier ist die erste Zeile:
0.500000,0.614231,0.567667,0.580000,0.787222,0.510333,0.797333,0.732000,0.851228,0.804333,0.764000,0.730667,0.879667,0.778667,0.858333,0.726333,0.884000,0.772667,0.959545,0.919667
Ich möchte eine Tabelle erstellen, um die Daten auszudrucken, abergekürzt, ich meine, drucken Sie nur 3 Dezimalstellen, wie x.xxx
.
Ich weiß, dass es \csvloop{}
den Schlüssel tabular={}
zum Angeben des Formats gibt (wie tabular={lSS[table-format=2.2e1]}
aus dem oben zitierten Beispiel).
Da meine Tabelle 20 Spalten haben soll, ist es möglich,alles automatisch formatieren?
Welches Format soll es sein
S[table-format=1.3]
??
MWE
Der folgende Code erzeugt den FehlerYou can't use a prefix with \hskip.}
\documentclass{report}
\usepackage{filecontents}
\usepackage{csvsimple}
\usepackage{siunitx}
\usepackage{array}
\begin{document}
\begin{filecontents*}{tab2.csv}
0.500000,0.614231,0.567667,0.580000,0.787222,0.510333,0.797333,0.732000,0.851228,0.804333,0.764000,0.730667,0.879667,0.778667,0.858333,0.726333,0.884000,0.772667,0.959545,0.919667
0.000000,0.500000,0.867308,0.891667,0.763889,0.694872,0.785256,0.729647,0.844298,0.797917,0.709455,0.675641,0.876282,0.741667,0.851442,0.710256,0.880128,0.694872,0.949519,0.912500
\end{filecontents*}
%
\csvloop{
file=tab2.csv,
tabular=*{20}{S[table-format=1.3,round-mode=places,round-precision=3]},
}
\end{document}
Antwort1
\documentclass{article}
\usepackage{csvsimple}
\usepackage{siunitx}
\usepackage{filecontents}
\begin{filecontents*}{BC14.csv}
0.500000,0.614231,0.567667,0.580000,0.787222,0.510333,0.797333,0.732000,0.851228,0.804333,0.764000,0.730667,0.879667,0.778667,0.858333,0.726333,0.884000,0.772667,0.959545,0.919667
0.000000,0.500000,0.867308,0.891667,0.763889,0.694872,0.785256,0.729647,0.844298,0.797917,0.709455,0.675641,0.876282,0.741667,0.851442,0.710256,0.880128,0.694872,0.949519,0.912500
\end{filecontents*}
\setlength{\tabcolsep}{1pt}
\begin{document}
{
\footnotesize
\csvreader[%
no head,
before reading=\sisetup{table-format=1.3,round-mode=places,round-precision=3},
tabular={c@{} *{20}{S}},
]{BC14.csv}{}{%
& \csvcoli & \csvcolii & \csvcoliii & \csvcoliv & \csvcolv & \csvcolvi & \csvcolvii & \csvcolviii & \csvcolix & \csvcolx & \csvcolxi & \csvcolxii & \csvcolxiii & \csvcolxiv & \csvcolxv & \csvcolxvi & \csvcolxvii & \csvcolxviii & \csvcolxix & \csvcolxx
}
}
\end{document}