我试图打开
https://gist.github.com/robertwb/22aa4dbfb6bcecd94f2176caa912b952
(见上文)pgfplotstable
。但我收到了几个错误和警告:
Package pgfplots Error: Table 'Periodic Table of Elements.csv' appears to have too many columns in l
ine 25: Ignoring ''. PGFPlots found that the number of columns is larger than t
he previously determined number of columns. Please verify that every cell entry
is separated correctly (use braces {<cell entry>} if necessary. Also verify th
at column names are plain ASCII.). This error is not critical.
有人能告诉我我该怎么办吗?
\documentclass[a4paper, landscape]{article}
\usepackage[margin=2cm, showframe=false]{geometry}
\usepackage{pgfplotstable}
\pgfplotsset{compat=newest}
\pgfplotstableread[col sep = comma]{Periodic Table of Elements.csv}{\psetable}
\begin{document}
\section{Table -- does not work}
%\pgfplotstabletypeset[string type]{\psetable}
\section{Element -- does not work}
%\pgfplotstablegetelem{1}{1}\of{\psetable}
%\pgfplotsretval
\end{document}
答案1
错误信息显示:
软件包 pgfplots 错误:表“元素周期表.csv”的第 25 行似乎有太多列:忽略“”。PGFPlots 发现列数大于先前确定的列数。请验证每个单元格条目是否正确分隔(如有必要,请使用括号 {}。还要验证列名是否为纯 ASCII。)。此错误并不严重。
如果你检查第 25 行,你会看到:
25,Manganese,Mn,54.938,30,25,25,4,7,solid,,yes,yes,,,Transition Metal,1.8,1.55,7.434,7.44E+00,1519.15,2334,11,"Gahn, Scheele",1774,0.479,4,
导致错误的罪魁祸首是"Gahn, Scheele"
被解释为两列。您需要用括号替换引号,如错误所述。在 csv 文件中,只有三行带引号,因此您可以手动执行此操作,也可以sed
在其上运行:
sed 's_\"_\{_; s_\"_\}_'
修复剩余的 unicode 错误后,您的代码几乎可以运行。\pgfplotstablegetelem
将行的名称作为第二个参数,或者您必须使用[index]
给出数值。要么
\pgfplotstablegetelem{1}{[index]1}\of{\psetable}
或者
\pgfplotstablegetelem{1}{Element}\of{\psetable}
将工作。