
我的 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}
(我更改了文件名,然後將其編輯回來。)