M. Edward (Ed) Borasky wrote: > A CSV file is (usually) very much like a database table. And an XML > document is (usually) a tree. A hash of hashes of arrays is an > inefficient way to store a tree. > > You need an algorithm and a data structure tuned to the algorithm and > the data. I would recommend starting from the required output and > working backwards to the input data. Have a look at the Ruby libraries > devoted to dealing with XML documents, and the Ruby libraries devoted to > dealing with CSV files. Let the XML libraries build the data structure, > rather than creating your own. Thanks for the response. You are right that my CSV file is very much like a database table (used to load database tables). However, my XML document is not so tree-like and actually fits pretty well into a hash of hashes of arrays. I am looking into the XML libraries - seems like a much neater way of writing out XML. Jeremy