In PatLet form...
One cannot efficiently represent and process external data using an interpreted (scripting) language.
Therefore
Write a BootStrap script that examines the external data and builds another script that represents the external data using scripting commands and their arguments as a data structure. Define the commands used in the script to perform processing actions. Execute the script to process the representation of the external data.
See http://www-dse.doc.ic.ac.uk/~np2/patterns/scripting for a more detailed description.