This uses my readarray package. It relies on there being space separators between fields, and exactly 3 fields in each row: <variable> = <value>. See ADDENDUM for improved version.
EDITED (12/2016) to use preferred syntax of upgraded readarray package, namely, \MyDat[\arabic{datacount},3] in lieu of deprecated \arrayij{MyDat}{\arabic{datacount}}{3}. Likewise, \readarray\data\MyDat[-,3] in lieu of \readArrayij{\data}{MyDat}{3}.
Note also that \value{datacount} of original answer was necessarily revised to \arabic{datacount}, as well.
\documentclass{article}
\usepackage{readarray}[2016-11-07]
\usepackage{filecontents}
\begin{filecontents*}{mydata.dat}
foo = 10
bar = 20
\end{filecontents*}
\newcommand\missingcommand[1]{\csname DATA#1\endcsname}
\begin{document}
\readdef{mydata.dat}{\data}
\readarray\data\MyDat[-,3]
\MyDatROWS{} rows of data read.
\newcounter{datacount}
\setcounter{datacount}{0}%
\whiledo{\value{datacount} < \MyDatROWS}{%
\stepcounter{datacount}%
\expandafter\xdef\csname DATA\MyDat[\arabic{datacount},1]\endcsname{%
\MyDat[\arabic{datacount},3]}%
}
The first value \missingcommand{foo} and the second value \missingcommand{bar}.
\end{document}

ADDENDUM
Note that with latest readarray package version, the field separator can be set to other characters or strings. Thus, for this application, it would be preferable to set the field separator as the = character (using \readarraysepchar{=}), so that spaces around the = sign are not a requirement. Then, using the starred version of the new/improved \readarray, leading/trailing spaces can be excised automatically from the data. Thus, the best version of the above code, producing identical results, can be given as
\documentclass{article}
\usepackage{readarray}[2016-11-07]
\usepackage{filecontents}
\begin{filecontents*}{mydata.dat}
foo = 10
bar=20
\end{filecontents*}
\newcommand\missingcommand[1]{\csname DATA#1\endcsname}
\readarraysepchar{=}
\begin{document}
\readdef{mydata.dat}{\data}
\readarray*\data\MyDat[-,2]
\MyDatROWS{} rows of data read.
\newcounter{datacount}
\setcounter{datacount}{0}%
\whiledo{\value{datacount} < \MyDatROWS}{%
\stepcounter{datacount}%
\expandafter\xdef\csname DATA\MyDat[\arabic{datacount},1]\endcsname{%
\MyDat[\arabic{datacount},2]}%
}
The first value \missingcommand{foo} and the second value \missingcommand{bar}.
\end{document}
datatoolsolution. +1 – Steven B. Segletes Aug 03 '16 at 15:01thekeyis only one character. – Azor Ahai -him- May 23 '17 at 03:56thekeyis only one character, you have to place it between quotation marks, e.g."f" = 10. I have to say that I do not really now why you have to do it. – Michael P Jun 16 '17 at 11:31