我有一个相当大的.csv
文件,我不想手动输入到 LaTeX 中,所以我想使用该csvsimple
包来导入它。csv 有 51 行,前几行如下所示:
State,Number of Dams,Land Area (km\textsuperscript{2}),Density of Dams (dams / km\textsuperscript{2}),Number of Dam Removals,Percent of Dams Removed,Number of Dam Removals with \ge 1 Publication,Percent of Dam Removals with \ge 1 Publication
Alabama,2267,"131,171",0.0173,8,0.35,0,0
Alaska,110,"1,477,953",0.0001,10,9.09,NA,NA
Arizona,372,"294,207",0.0013,3,0.81,1,33.33
Arkansas,1267,"134,771",0.0094,4,0.32,0,0
California,1529,"403,466",0.0038,173,11.31,4,2.31
无论我如何尝试,我总是得到:
不完整 \iffalse,行 <> 之后的所有文本被忽略
我的文件可能出了什么问题以致于无法读取?
*编辑
我通过从列标题中删除所有格式并调用来使其工作,\csvautotabulate{Dam_info_breakdown.csv}.
现在我遇到了一个问题,我似乎无法让它适合页面。
\documentclass[12pt]{article}
\usepackage{csvsimple}
\usepackage{longtable}
\usepackage{booktabs}
\begin{document}
\csvreader[
longtable=lrrrr,
table head=\toprule State & Number of Dams & Land Area & Density of Dams & Number of Dam Removals & Percent of Dams Removed & Number of Dam Removals with at Least One Publication & Percent of Dam Removals with at Least One Publication \\\midrule,
late after line=\\,
late after last line=\\\bottomrule,
]{Dam_info_breakdown.csv}{1=\State,2=\NumDam,3=\Area,4=\DensDams,5=\NumRems,6=\PercentRems,7=\NumPubs,8=\PercentPubs}{\State & \NumDam & \Area & \DensDams & \NumRems & \PercentRems & \NumPubs & \PercentPubs}
\end{document}
不工作,也没有给我提供有用的错误代码,它只是死机了。
*编辑2:这使得它工作
\csvreader[
longtable=|r|*{7}{p{1.5cm}}|,
table head=\toprule State & Number of Dams & Land Area (km\textsuperscript{2}) & Density of Dams (dams / km\textsuperscript{2}) & Number of Dam Removals & Percent of Dams Removed & Number of Dam Removals with at Least One Publication & Percent of Dam Removals with at Least One Publication \\\midrule,
late after line=\\,
late after last line=\\\bottomrule,
]{Dam_info_breakdown.csv}{1=\State,2=\NumDam,3=\Area,4=\DensDams,5=\NumRems,6=\PercentRems,7=\NumPubs,8=\PercentPubs}{\State & \NumDam & \Area & \DensDams & \NumRems & \PercentRems & \NumPubs & \PercentPubs}