From this question: Cannot use \toprule when doing \input inside tabular -- why? I know that everything inside the tabular environment should better be expandable. The MWE below suggests that \InputIfFileExists is not, although the error message is different now:
! Missing \endcsname inserted.
<to be read again>
\def
l.8 \end{tabular}
File main.tex:
\documentclass{standalone}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{ll}
\InputIfFileExists{inp.tex}{}{}
\end{tabular}
\end{document}
File inp.tex:
\toprule
a & b \\
c & d \\
\bottomrule
How do I check, in an expandable fashion, if a file exists and input it if it does?
The following question is related: Why is \input not expandable?
This is my first LuaTeX code, so please bear with me. 

standalonepackage for the automated build feature. Using Lua code like this might be the way (if LuaTeX is used of course). Do you now a way to get the full absolute path of the file or the full relative path from the current directory? – Martin Scharrer Apr 28 '12 at 08:24abspathfunction to get the absolute path of a file. To get the full path of the current directory, you could userequire 'lfs'andlfs.currentdir(). – Paulo Cereda Apr 28 '12 at 10:51:)– Paulo Cereda Mar 03 '13 at 10:09