Don't you have a full list of the fields? Writing code to alter structure on import is risky.Update:
Thinking of using an xslt transformation in php to alter the data to format it correctly for the import. I used to do this extensively about 10 years ago in visual studio. But don't remember if you are able to add a column with data during a transformation.
Or just add the Filename field using the xml DOM and populate it before importing it into the DB.
Am I over thinking this?