You definitely don’t want to use eval
for this, because that could inject arbitrary code into your program via the data file.
Most likely you only support a relatively small set of element types, in which case you can use a dictionary mapping supported type strings to the corresponding types. Dict("Float32"=>Float32,"Int16"=>Int16,...)