这个问题至少可以说非常奇怪。我有一个关于几个宏观经济指标的 12 列 csv 文件:
n,pibreal,pibnom,deflactor,c,isr,trc,tdeflactado,trcdeflactado,I,x,m
2000,1059317580733.46,393302970000,37.127956446,281965700000,10616220000,437870990000,3941585537.81615,162572550457.059,109702668399.757,139614000000,172276800000
2001,1082466050569.29,427319070000,39.4764408339,300954300000,15409220000,447232010000,6083011616.26492,176551279817.895,114396066342.969,136274700000,165030400000
2002,1128392235489.82,477430190000,42.3106589166,335857300000,16166240000,338898720000,6840042666.04618,143390281492.075,128699689772.917,146685700000,181420000000
2003,1110119525916.62,628611040000,56.6255277314,453212600000,19903830000,312522800000,11270648776.2678,176967684781.06,122008139726.167,264978400000,265880500000
2004,1136920845139.83,935984730000,82.3262880614,663061200000,24380340000,278650080000,20071428938.7504,229402267544.141,193068834546.586,385134100000,376302800000
2005,1242447543857.26,1083445000000,87.2024742901,781476100000,29919960000,304195780000,26090945426.6056,265266246846.043,268402600855.057,306952300000,361030100000
2006,1353859075481.57,1261399670000,93.1706772768,903196900000,38954770000,232809480000,36294423040.6312,216910169280.665,339655467614.886,356029000000,448321200000
2007,1455253260300.12,1455253260300.12,100,1028340106626.27,55713270000,187362070000,55713270000,187362070000,413484099269.877,390475504120.436,510886323057.287
2008,1503061927458.95,1656961744055.34,110.2390868789,1215394185261.69,58252840000,162377730000,64217398897.0342,179003726846.707,498715830537.822,397469645748.566,620524420197.88
2009,1513348643542.65,1729468428699.59,114.2808985939,1276354253008.9,54168480000,121031490000,61904225698.6731,138315874353.622,414195624115.801,365381960826.093,509650082429.96
2010,1638697922673.49,1978851884596.09,120.7575757079,1475592123331.43,53750500000,75333100000,64907800730.8705,90970425265.602,527505380784.85,433869092753.816,651040957447.698
2011,1688841703851.69,2218428824292.59,131.3580082274,1233480264844.07,65218700000,11002340000,85669985311.7773,14452454682.4021,556020587537.167,525750765136.529,749797745712.548
2012,1730752476014.56,2377503668802.55,137.3682084383,1786146992638.45,318558732261.06,11832120000,437598423330.748,16253571264.2686,548109131163.141,580512510875.323,786487854482.959
2013,1834292875289.9,2558585610654.53,139.4862099244,1889709894858.51,369413000000,10100470000,515280192667.892,14088762787.5474,558352865212.123,650889248254.709,797757282239.087
2014,1959496848092.36,2786229703801.94,142.1910786187,2018227692393.27,417439800000,,593562154203.741,41485368130.1524,600017741550.596,744803898213.531,874637508968.428
我使用了一个非常短的 tex 文件来重现该问题:
\documentclass{article}
\usepackage{csvsimple}
\begin{document}
\begin{tabular}{|l|r|r|}%
\bfseries Año & \bfseries PIB & \bfseries Consumo privado%
\csvreader{test.csv}{}%
{\\ \hline \csvcoli & \csvcoliii & \csvcoliiiii}%
\end{tabular}
\end{document}
起初我假设问题与标题有关,因此使用命令\csvcol
而不是声明列名,结果相同。
! Undefined control sequence.
\csv@@body ...csvcoli & \csvcoliii & \csvcoliiiii
l.10 ...line \csvcoli & \csvcoliii & \csvcoliiiii}
%
? x
完整的日志文件
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) (preloaded format=pdflatex 2015.11.17) 16 MAY 2016 21:29
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**test.tex
(./test.tex
LaTeX2e <2015/10/01> patch level 1
Babel <3.9m> and hyphenation patterns for 5 languages loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
)
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
(/usr/share/texlive/texmf-dist/tex/latex/csvsimple/csvsimple.sty
Package: csvsimple 2014/07/14 version 1.12 LaTeX CSV file processing
(/usr/share/texlive/texmf-dist/tex/latex/pgf/utilities/pgfkeys.sty
(/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
\pgfkeys@pathtoks=\toks14
\pgfkeys@temptoks=\toks15
(/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.code.t
ex
\pgfkeys@tmptoks=\toks16
))) (/usr/share/texlive/texmf-dist/tex/latex/base/ifthen.sty
Package: ifthen 2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)
)
\csv@file=\read1
\c@csvinputline=\count87
\c@csvrow=\count88
\c@csvcol=\count89
\csv@out=\write3
) (./test.aux)
\openout1 = `test.aux'.
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 5.
LaTeX Font Info: ... okay on input line 5.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <7> on input line 7.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <5> on input line 7.
Missing character: There is no � in font cmbx10!
Missing character: There is no � in font cmbx10!
! Undefined control sequence.
\csv@@body ...csvcoli & \csvcoliii & \csvcoliiiii
l.10 ...line \csvcoli & \csvcoliii & \csvcoliiiii}
%
? x
Here is how much of TeX's memory you used:
1148 strings out of 494903
26707 string characters out of 6179138
73889 words of memory out of 5000000
4498 multiletter control sequences out of 15000+600000
3948 words of font info for 15 fonts, out of 8000000 for 9000
40 hyphenation exceptions out of 8191
40i,6n,46p,272b,210s stack positions out of 5000i,500n,10000p,200000b,80000s
No pages of output.
PDF statistics:
0 PDF objects out of 1000 (max. 8388607)
0 named destinations out of 1000 (max. 500000)
1 words of extra memory for PDF output out of 10000 (max. 10000000)
以下示例这个答案构建过程没有问题。
答案1
您需要第 1、3 和 5 列,它们分别由\csvcoli
、\csvcoliii
和给出\csvcolv
(使用罗马数字转换)。因此,不是\csvcoliiiii
,而是\csvcolv
:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{test.csv}
n,pibreal,pibnom,deflactor,c,isr,trc,tdeflactado,trcdeflactado,I,x,m
2000,1059317580733.46,393302970000,37.127956446,281965700000,10616220000,437870990000,3941585537.81615,162572550457.059,109702668399.757,139614000000,172276800000
2001,1082466050569.29,427319070000,39.4764408339,300954300000,15409220000,447232010000,6083011616.26492,176551279817.895,114396066342.969,136274700000,165030400000
2002,1128392235489.82,477430190000,42.3106589166,335857300000,16166240000,338898720000,6840042666.04618,143390281492.075,128699689772.917,146685700000,181420000000
2003,1110119525916.62,628611040000,56.6255277314,453212600000,19903830000,312522800000,11270648776.2678,176967684781.06,122008139726.167,264978400000,265880500000
2004,1136920845139.83,935984730000,82.3262880614,663061200000,24380340000,278650080000,20071428938.7504,229402267544.141,193068834546.586,385134100000,376302800000
2005,1242447543857.26,1083445000000,87.2024742901,781476100000,29919960000,304195780000,26090945426.6056,265266246846.043,268402600855.057,306952300000,361030100000
2006,1353859075481.57,1261399670000,93.1706772768,903196900000,38954770000,232809480000,36294423040.6312,216910169280.665,339655467614.886,356029000000,448321200000
2007,1455253260300.12,1455253260300.12,100,1028340106626.27,55713270000,187362070000,55713270000,187362070000,413484099269.877,390475504120.436,510886323057.287
2008,1503061927458.95,1656961744055.34,110.2390868789,1215394185261.69,58252840000,162377730000,64217398897.0342,179003726846.707,498715830537.822,397469645748.566,620524420197.88
2009,1513348643542.65,1729468428699.59,114.2808985939,1276354253008.9,54168480000,121031490000,61904225698.6731,138315874353.622,414195624115.801,365381960826.093,509650082429.96
2010,1638697922673.49,1978851884596.09,120.7575757079,1475592123331.43,53750500000,75333100000,64907800730.8705,90970425265.602,527505380784.85,433869092753.816,651040957447.698
2011,1688841703851.69,2218428824292.59,131.3580082274,1233480264844.07,65218700000,11002340000,85669985311.7773,14452454682.4021,556020587537.167,525750765136.529,749797745712.548
2012,1730752476014.56,2377503668802.55,137.3682084383,1786146992638.45,318558732261.06,11832120000,437598423330.748,16253571264.2686,548109131163.141,580512510875.323,786487854482.959
2013,1834292875289.9,2558585610654.53,139.4862099244,1889709894858.51,369413000000,10100470000,515280192667.892,14088762787.5474,558352865212.123,650889248254.709,797757282239.087
2014,1959496848092.36,2786229703801.94,142.1910786187,2018227692393.27,417439800000,,593562154203.741,41485368130.1524,600017741550.596,744803898213.531,874637508968.428
\end{filecontents*}
\usepackage[utf8]{inputenc}
\usepackage{csvsimple}
\begin{document}
\begin{tabular}{|l|r|r|}%
\bfseries Año & \bfseries PIB & \bfseries Consumo privado%
\csvreader{test.csv}{}%
{\\ \hline \csvcoli & \csvcoliii & \csvcolv}%
\end{tabular}
\end{document}