in reply to Sorting Data By Overlapping Intervals

Would it be beneficial to use a database, and then compose the appropriate SQL queries to process your data?

You might benefit from abstracting the file handling part from the data munging part. You'd also be able to tweak the queries and review the outputs until you get them just right.

What can be asserted without proof can be dismissed without proof. - Christopher Hitchens, 1949-2011