# LaTex Package PGF Math Error with pgfplotstable

I try to create a table in Latex using the data and the code below. However, Texmaker keep giving me the "! Package PGF Math Error: Could not parse input 'fdcexp' as a floating point nu". Can anyone please help me to fix this?

 \documentclass[12pt,a4paper]{article}
\usepackage{float}
\usepackage{pgfplotstable,pgfplots,booktabs,filecontents,pdflscape}
\newcolumntype{M}{>{$}c<{$}}
\begin{document}
\begin{filecontents}{result3.dat}
model,modelx
,y3
fdcexp,0.402**
,-2.19
L.gdpper,-0.00472
,(-1.63)
growth,0.138
,-0.29
D.lnhuman,-0.533
,(-0.60)
ligdp,-0.251
,(-1.55)
2002.obs,0
,(.)
2003.obs,0.356
,-1.44
2004.obs,0.262
,-1.02
2005.obs,0.605**
,-2.32
2006.obs,0.707***
,-2.6
2007.obs,1.407***
,-4.97
2008.obs,1.943***
,-6.67
2009.obs,2.187***
,-6.77
2010.obs,2.324***
,-6.72
2011.obs,2.483***
,-6.67
2012.obs,2.817***
,-7.31
2013.obs,3.073***
,-8.48
2014.obs,3.495***
,-9.26
fdcall,
,
fdcave,
,
fdcnet,
,
fdcrev,
,
yr2007,
,
_cons,8.796***
,-4.23
N,259
r2_o,0.152
\end{filecontents}
\begin{landscape}
\centering\small
\setlength\tabcolsep{2.2pt}
\pgfplotstabletypeset[
col sep = comma,
display columns/model/.style={string type,column type={l}},
display columns/modelx/.style={string type},
]{result3.dat}
\end{landscape}
\end{document}

• I would guess that 0.402** gives a syntax error as floating point due to the * – David Carlisle May 9 '17 at 13:41
• Welcome to TeX.SX – jjdb May 9 '17 at 13:45
• In fact, the error is the letter as in the error message below, it says that the "unreadable part was near 'fdcexp'". I am not sure about the word "near" in this message. ! Package PGF Math Error: Could not parse input 'fdcexp' as a floating point number, sorry. The unreadable part was near 'fdcexp'.. – DB225681 May 9 '17 at 14:42

You have to use either display columns/0/.style or columns/model/.style, that means either

display columns/<column index>/.style


or

columns/<column name>/.style


Because of the _ in the cells the column model needs string replace*={_}{\_},.

Your table is too long, so I remove some lines for the example. Maybe you have to use longtable.

\documentclass[12pt,a4paper]{article}
\usepackage{pgfplotstable}
\usepackage{pdflscape}
\usepackage{filecontents}

\begin{document}
\begin{filecontents}{result3.dat}
model,modelx
,y3
fdcexp,0.402**
,-2.19
L.gdpper,-0.00472
,(-1.63)
growth,0.138
,-0.29
D.lnhuman,-0.533
,(-0.60)
ligdp,-0.251
,(-1.55)
2002.obs,0
,(.)
2003.obs,0.356
,-1.44
fdcall,
,
fdcave,
,
yr2007,
,
_cons,8.796***
,-4.23
N,259
r2_o,0.152
\end{filecontents}
\begin{landscape}
\centering\small
\setlength\tabcolsep{2.2pt}
\pgfplotstabletypeset[
col sep = comma,
display columns/0/.style={string type,string replace*={_}{\_},column type={l}},
columns/modelx/.style={string type},
]{result3.dat}
\end{landscape}
\end{document}


results in

Here is an additional suggestion with your long table using package longtable as already suggested above:

\documentclass[12pt,a4paper]{article}
\usepackage{pgfplotstable}
\usepackage{pdflscape}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{filecontents}

\begin{document}
\begin{filecontents}{result3.dat}
model,modelx
,y3
fdcexp,0.402**
,-2.19
L.gdpper,-0.00472
,(-1.63)
growth,0.138
,-0.29
D.lnhuman,-0.533
,(-0.60)
ligdp,-0.251
,(-1.55)
2002.obs,0
,(.)
2003.obs,0.356
,-1.44
2004.obs,0.262
,-1.02
2005.obs,0.605**
,-2.32
2006.obs,0.707***
,-2.6
2007.obs,1.407***
,-4.97
2008.obs,1.943***
,-6.67
2009.obs,2.187***
,-6.77
2010.obs,2.324***
,-6.72
2011.obs,2.483***
,-6.67
2012.obs,2.817***
,-7.31
2013.obs,3.073***
,-8.48
2014.obs,3.495***
,-9.26
fdcall,
,
fdcave,
,
fdcnet,
,
fdcrev,
,
yr2007,
,
_cons,8.796***
,-4.23
N,259
r2_o,0.152

\end{filecontents}
\begin{landscape}
\centering\small
\setlength\tabcolsep{2.2pt}
\pgfplotstabletypeset[
col sep = comma,
begin table=\begin{longtable},
end table=\end{longtable},
before row={\caption{My Table}\label{tbl:MyTable}\\\toprule},
after row={
\multicolumn{2}{l}{{\scriptsize Table \thetable\ continued from previous page}}\\
\midrule
model&modelx\\
\midrule
\midrule
\multicolumn{2}{r}{{\scriptsize Continued on next page}}
\endfoot
\bottomrule
\endlastfoot
}
},
display columns/0/.style={string type,string replace*={_}{\_},column type={l}},
columns/modelx/.style={string type},
]{result3.dat}
\end{landscape}
\end{document}


Run several times to get:

And an example with more columns in the data file, but only two in the output:

\documentclass[12pt,a4paper]{article}
\usepackage{pgfplotstable}
\usepackage{pdflscape}
\usepackage{filecontents}

\begin{document}
\begin{filecontents}{result8.dat}
model,modela,modelb,modelc,modeld,modele,modelf,modelg
,y3,fdcexp,0.402**, ,-2.19,L.gdpper,-0.00472
,(-1.63),growth,0.138,,-0.29,D.lnhuman,-0.533
,(-0.60),ligdp,-0.251,,(-1.55),2002.obs,0
,(.),2003.obs,0.356,,-1.44,2004.obs,0.262
2005.obs,0.605**,,-2.32,2006.obs,0.707***,,-2.6
fdcall,,,fdcave,,,fdcnet,
_cons,8.796***,,-4.23,N,259,r2_o,0.152
\end{filecontents}
\begin{landscape}
\centering\small
\setlength\tabcolsep{2.2pt}
\pgfplotstabletypeset[
col sep = comma,
columns={model,modela},
display columns/0/.style={string type,string replace*={_}{\_},column type={l}},
columns/modela/.style={string type}
]{result8.dat}
\end{landscape}
\end{document}


or all columns in the output

\documentclass[12pt,a4paper]{article}
\usepackage{pgfplotstable}
\usepackage{pdflscape}
\usepackage{filecontents}

\begin{document}
\begin{filecontents}{result8.dat}
model,modela,modelb,modelc,modeld,modele,modelf,modelg
,y3,fdcexp,0.402**, ,-2.19,L.gdpper,-0.00472
,(-1.63),growth,0.138,,-0.29,D.lnhuman,-0.533
,(-0.60),ligdp,-0.251,,(-1.55),2002.obs,0
,(.),2003.obs,0.356,,-1.44,2004.obs,0.262
2005.obs,0.605**,,-2.32,2006.obs,0.707***,,-2.6
fdcall,,,fdcave,,,fdcnet,
_cons,8.796***,,-4.23,N,259,r2_o,0.152
\end{filecontents}
\begin{landscape}
\centering\small
\setlength\tabcolsep{2.2pt}
\pgfplotstabletypeset[
col sep = comma,
string type,
display columns/0/.style={string replace*={_}{\_},column type={l}},
display columns/6/.style={string replace*={_}{\_}}
]{result8.dat}
\end{landscape}
\end{document}


• Thank you. I find the problem only exists when I increase the size of the table. For example, if I add 4 or 5 more columns, the code won't work. But unfortunately, I usually work with large table of results. – DB225681 May 9 '17 at 18:24
• @TUNGBUI I have added an example with 8 columns. Note that you really have to use either display columns/<column index>/.style or columns/<column name>/.style to change the style for single columns. – esdd May 9 '17 at 20:12
• I much appreciate your help. So I observed that only the columns with the character "_" hinder the compilation. Is that true? – DB225681 May 10 '17 at 6:45