我的 csv 由制表符分隔。
\csvautotabular
当使用该选项加载时,separator=tab
它工作正常。但是当使用 加载时,\csvreader
就像在文档示例中一样,它只会打印出第一行数据。
查看输出的图片附在最后。
我的带有标签的文件(table-data/parse_size_out.tsv):
benchmark num_post_packed_blocks num_clb
ch_intrinsics.v 295 65
diffeq1.v 299 36
diffeq2.v 198 29
mkPktMerge.v 509 27
raygentop.v 634 106
stereovision3.v 54 13
用逗号重新格式化(table-data/parse_size_out_commas.csv):
benchmark,num_post_packed_blocks,num_clb
ch_intrinsics.v,295,65
diffeq1.v,299,36
diffeq2.v,198,29
mkPktMerge.v,509,27
raygentop.v,634,106
stereovision3.v,54,13
梅威瑟:
\documentclass{article}
\usepackage{csvsimple}
\begin{document}
\csvautotabular[
separator=tab,
respect underscore=true
]{table-data/parse_size_out.tsv}
\vspace{1cm}
\begin{tabular}{|l|c|}\hline%
\bfseries Benchmark & \bfseries \#blocks
\csvreader[
separator=tab,
respect underscore=true,
head to column names
]{table-data/parse_size_out.tsv}{benchmark=\benchmark,num_post_packed_blocks=\numblocks}{%
\\\benchmark & \numblocks
}%
\\\hline
\end{tabular}
\vspace{1cm}
\begin{tabular}{|l|c|}\hline%
\bfseries Benchmark & \bfseries \#blocks
\csvreader[
respect underscore=true,
head to column names
]{table-data/parse_size_out_commas.csv}{benchmark=\benchmark,num_post_packed_blocks=\numblocks}{%
\\\benchmark & \numblocks
}%
\\\hline
\end{tabular}
\end{document}
\csvautotabular
:
\csvreader
带有标签文件:
\csvreader
使用带逗号的文件:
答案1
您应该加载(维护)l3
版本。
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[l3]{csvsimple}
\begin{document}
\csvautotabular[
separator=tab,
respect underscore=true
]{a.tsv}
\vspace{1cm}
\begin{tabular}{|l|c|}\hline
\bfseries Benchmark & \bfseries \#blocks
\csvreader[
separator=tab,
respect underscore=true,
head to column names
]{a.tsv}{benchmark=\benchmark,num_post_packed_blocks=\numblocks}{%
\\\benchmark & \numblocks
}
\\\hline
\end{tabular}
\vspace{1cm}
\begin{tabular}{|l|c|}\hline
\bfseries Benchmark & \bfseries \#blocks
\csvreader[
respect underscore=true,
head to column names
]{b.csv}{benchmark=\benchmark,num_post_packed_blocks=\numblocks}{%
\\\benchmark & \numblocks
}
\\\hline
\end{tabular}
\end{document}
(我更改了文件名,请将其编辑回来。)