有没有一种合适、快速的方法来打印塞莱罗输出(CSV)作为表格?
答案1
我找到了一种以横向、多页方式打印的好方法:您需要以下包:ltablex
,multirow
和pgfplotstable
。
\begin{landscape}
\newcommand{\headerCSV}{Group & Experiment & Problem Space & Samples & Iterations & Baseline & us/Iteration & Iterations/sec & Min (us) & Mean (us) & Max (us) & Variance & Standard Deviation & Skewness & Kurtosis & Z Score} % own Header
\setlength\tabcolsep{1.5pt} % save inner margin space
{\tiny
\pgfplotstableread[col sep=comma]{diagrams/results.csv}\data % Your CSV file
\pgfplotstabletypeset[%
begin table=\begin{tabularx}{\hsize},
% Multi Page setup:
every first row/.append style={before row={%
\headerCSV \\ \hline
\endfirsthead
\multicolumn{16}{c}%
{\textbf{Continued from previous page}} \\
\hline
\headerCSV \\ \hline
\endhead
\hline
\multicolumn{16}{c}%
{\textbf{Continued on next page}} \\
\endfoot
\hline
\multicolumn{16}{|r|}{{Concluded}} \\
\hline
\endlastfoot
}
},%
end table=\end{tabularx},
%
column type/.add={|}{},
empty cells with={---}, %replace empty cells with ’--’
% Custom columns settings for every Celero output row
columns/Group/.style={string type, column type=|l},
columns/Experiment/.style={string type, column type=|l},
columns/Problem Space/.style={string replace={-9223372036854775808}{}, column type=|X}, % no Problem Space --> empty
columns/Samples/.style={column type=|X},
columns/Iterations/.style={column type=|X},
columns/Baseline/.style={column type=|X},
columns/us/Iteration/.style={column type=|X},
columns/Iterations/sec/.style={column type=|X},
columns/Min (us)/.style={column type=|X},
columns/Mean (us)/.style={column type=|X},
columns/Max (us)/.style={column type=|X},
columns/Variance/.style={column type=|X},
columns/Standard Deviation/.style={column type=|X},
columns/Skewness/.style={column type=|X},
columns/Kurtosis/.style={column type=|X},
columns/Z Score/.style={column type=|X|},
every head row/.style={%
after row=\hline,output empty row
},
columns={Group,Experiment,Problem Space,Samples,Iterations,Baseline,us/Iteration,Iterations/sec,Min (us),Mean (us),Max (us),Variance,Standard Deviation,Skewness,Kurtosis,Z Score},%
/pgf/number format/fixed,
/pgf/number format/precision=5,
]{\data}
} % end tiny
\end{landscape}
编辑:致谢@harish-kumar基本概念。
完整 MWE:
\documentclass[%
pdftex,
a4paper,
%letterpaper,
oneside, % Einseitiger Druck.
12pt, % Schriftgroesse
parskip=half, % Halbe Zeile Abstand zwischen Absätzen.
% headsepline, % Linie nach Kopfzeile.
footsepline, % Linie vor Fusszeile.
plainfootsepline,
abstracton, % Abstract Überschriften
english, % Translator
%enabledeprecatedfontcommands, %enable old commands ot use fancyhdr NOT RECOMMENDED
]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{lscape}
\usepackage{pgfplotstable}
\usepackage{ltablex} % mix out of tabularx and longtable
\usepackage{multirow}
\begin{document}
\begin{landscape}
\newcommand{\headerCSV}{Group & Experiment & Problem Space & Samples & Iterations & Baseline & us/Iteration & Iterations/sec & Min (us) & Mean (us) & Max (us) & Variance & Standard Deviation & Skewness & Kurtosis & Z Score} % own Header
\setlength\tabcolsep{1.5pt} % save inner margin space
{\tiny
\pgfplotstableread[col sep=comma]{results.csv}\data % Your CSV file
\pgfplotstabletypeset[%
begin table=\begin{tabularx}{\hsize},
% Multi Page setup:
every first row/.append style={before row={%
\headerCSV \\ \hline
\endfirsthead
\multicolumn{16}{c}%
{\textbf{Continued from previous page}} \\
\hline
\headerCSV \\ \hline
\endhead
\hline
\multicolumn{16}{c}%
{\textbf{Continued on next page}} \\
\endfoot
\hline
\multicolumn{16}{|r|}{{Concluded}} \\
\hline
\endlastfoot
}
},%
end table=\end{tabularx},
%
column type/.add={|}{},
empty cells with={---}, %replace empty cells with ’--’
% Custom columns settings for every Celero output row
columns/Group/.style={string type, column type=|l},
columns/Experiment/.style={string type, column type=|l},
columns/Problem Space/.style={string replace={-9223372036854775808}{}, column type=|X}, % no Problem Space --> empty
columns/Samples/.style={column type=|X},
columns/Iterations/.style={column type=|X},
columns/Baseline/.style={column type=|X},
columns/us/Iteration/.style={column type=|X},
columns/Iterations/sec/.style={column type=|X},
columns/Min (us)/.style={column type=|X},
columns/Mean (us)/.style={column type=|X},
columns/Max (us)/.style={column type=|X},
columns/Variance/.style={column type=|X},
columns/Standard Deviation/.style={column type=|X},
columns/Skewness/.style={column type=|X},
columns/Kurtosis/.style={column type=|X},
columns/Z Score/.style={column type=|X|},
every head row/.style={%
after row=\hline,output empty row
},
columns={Group,Experiment,Problem Space,Samples,Iterations,Baseline,us/Iteration,Iterations/sec,Min (us),Mean (us),Max (us),Variance,Standard Deviation,Skewness,Kurtosis,Z Score},%
/pgf/number format/fixed,
/pgf/number format/precision=5,
]{\data}
} % end tiny
\end{landscape}
\end{document}