I'm not sure if it's necessary to use auxiliary files.
I made something implementing fake vectors using \csname . I think that a similar approach can be used for this problem, but I prefer to never see my old code again. IWIMM
\newcommand{\defwithindex}[3]{%
\expandafter\def\csname #1@#2\endcsname{#3}%
}
\newcommand{\getwithindex}[2]{%
\csname #1@#2\endcsname%
}
(You probably need the two dimensional version.)