you could use
fgetcsv, then foreach all the way through the result and create insert-statments.
that will probably be slower than what you do now, but it should work.
i didn't even now what you did there is possible, so thanks for the info, maybe there is another way.