From an example on StackExchange.
\documentclass{article}
\usepackage{pgfplotstable}
\usepackage{amsmath}
\begin{document}
\pgfplotstableread[header=has colnames]{matrix.dat}\mytable
\pgfplotstabletypeset[
begin table=\begin{pmatrix},
end table=\end{pmatrix},
skip coltypes,
write to macro=\mymatrix,
typeset=false
]{\mytable}
$\mymatrix$
\end{document}
An example using a hidden data file. Use the optional button below to see the data.