here's how I would approach this: a two part process, where the first process parses your data files, inserting variables names into each field:
( while read field1 field2 field3 field4 ; do
echo "f1='$field1'; f2='$field2'; f3='$field3'"
) < input-data-file > tempfile
then in a second loop, use the tempfile as input, feed it to the eval command, then simply substitute all occurances of, say, '$f1' with the actual value of the variable f1:
( while read inputline ; do
sed "s/\$f1/$f1/g;s/\$f2/$f2/g;s/\$f3/$f3/g" < templatefile
) < tempfile
I hope that makes sense. It might be slightly off with syntax since this is top of my head, but as long as your datafile is well formed (e.g., there's a common delimiter between fields (if it's not a space, change the IFS value to use that instead, btw).
Cheers and good luck!