I tried to hack this here for a larger case but it is firing errors. What is causing the too many columns
error and is Pgfplots ideal for this kind of table generation?
Goal: table that I am trying to reproduce with Pgfplots
MWE with pgfplots Error: Table 'anu1.csv' appears to have too many columns in line
\documentclass[11pt,english]{article}
\usepackage{pgfplotstable}
\usepackage{filecontents,booktabs}
\pgfplotsset{compat=1.9}% supress warning
\begin{document}
\begin{filecontents*}{anu1.csv}
Country, Total, <100 miles from Caspian Sea, Major Activities
Azerbaijan, 2, 2, SOCAR runs gas processing plants for Caspian basin fields including Shah Deniz.
Iran, 40, 0, --
Kazakhstan, 14, 3*, TengizChevrOil runs a gas processing plant to pick up associated gas from the Russia, 37, 2, Gazprom and LUKOil run gas processing plants for natural gas from the large AstrakhTurkmenistan, 2, 0, Iranian company Ramshir currently building processing plant for Korpezhe field
Uzbekistan, 4, 0, --
\end{filecontents*}
\begin{center}
\pgfplotstabletypeset[
string type,
col sep=comma,
columns={Country,Total,<100 miles from Caspian Sea,Major Activities},
columns/Country/.style={column type=l},
columns/Total/.style={column type=l},
columns/<100 miles from Caspian Sea/.style={column type=l},
columns/Major Activities/.style={column type=l},
every head row/.style={before row=\toprule,after row=\cmidrule(lr){1-1}\cmidrule(lr){2-2}},
every last row/.style={after row=\bottomrule}
]{anu1.csv}
\end{document}
Best Answer
Since you have really wide data you need to use a column type that allwos for wrapping. An easy way to do that is t use the
array
package to define two new column types as I have below. TheC
column type is used on the< 100 miles...
column as the header was really wide. TheP
column type is used to ensure that the last column is wrapped across multiple lines:Notes:
{}
since there was a comma in the text, but it appears to work without that.Code: