"If you want to adhere to these, I'm not sure you can do much but parse the files multiple times."

That was exactly what I was trying to avoid, for readability's sake :)

Otherwise most code in this example would deal with the specifics of the dataset and not with the problem at hand...