You can use pgfplotstable
for this. If you load the array
package, you can set the option dec sep align
for pgfplotstabletypeset
to get the alignment at the decimal point. Padding the numbers with zeros can be accomplished by setting fixed zerofill
, the number of decimals can be set using precision
, either for all columns or for individual columns by using display column/<index>/precision=<digits>
.

\documentclass{article}
\usepackage{filecontents} % For the example data
\usepackage{pgfplotstable}
\usepackage{array} % For aligining at decimal point
\begin{filecontents}{testdata.csv}
theta, x, y
30.0, 0.0, 0.0
60.0, 1.9098, 5.8779
90.0, 6.9098, 9.5106
120.0, 13.09, 9.5106
150.0, 18.09, 5.8779
180.0, 20.0, 0.0
\end{filecontents}
\begin{document}
\pgfplotstableread[col sep=comma]{testdata.csv}{\table}
\pgfplotstabletypeset[
dec sep align, % Align at decimal point
fixed zerofill, % Fill numbers with zeros
precision=4, % Set number of decimals
display columns/0/.style={precision=1}, % Change for first column (column 0)
] {\table}
\end{document}
Alternatively, you can use pgfplotstable
and the siunitx
package to align the columns. I've used it here in conjunction with booktabs and properly formatted column headers:

\documentclass{article}
\usepackage{pgfplotstable}
\usepackage{siunitx}
\usepackage{booktabs}
\begin{filecontents}{testdata.csv}
theta, x, y
30.0, 0.0, 0.0
60.0, 1.9098, 5.8779
90.0, 6.9098, 9.5106
120.0, 13.09, 9.5106
150.0, 18.09, 5.8779
180.0, 20.0, 0.0
\end{filecontents}
\begin{document}
\pgfplotstableread[col sep=comma]{testdata.csv}{\table}
\pgfplotstabletypeset[
dec sep align=S, % Use the siunitx `S` column type for aligning at decimal point
fixed zerofill, % Fill numbers with zeros
precision=4, % Set number of decimals
display columns/0/.style={
precision=1, % Change for first column (column index 0)
column name=$\theta_{2,i}$
},
display columns/1/.style={column name=$X$},
display columns/2/.style={column name=$Y$},
every head row/.style={before row=\toprule, after row=\midrule},
every last row/.style={after row=\bottomrule},
] {\table}
\end{document}