title: How can I read to dictionary keys in a way that make sense?
body: <p>I have about a thousand files that are named in a semi-sensible way like the following: </p>
  
  <pre><code>aaa.ba.ca.01
  aaa.ba.ca.02
  aaa.ba.ca.03
  
  aaa.ba.da.01
  aaa.ba.da.02
  aaa.ba.da.03
  </code></pre>
  
  <p>and so on. Let's say each file contains 2 columns of numbers which I need to read in to the dictionaries: wavelength, flux. The reading in part is easy for me, the hard part is that I need to load these dictionaries so that they store the information like:</p>
  
  <p>wavelength['aaa.ba.ca.01'] (which is the wavelengths of that one file)</p>
  
  <p>wavelength['aaa.ba.ca'] (which is the wavelengths of all subfiles ie ...ca.01, ...ca.02, and ...ca.03 -- in order)</p>
  
  <p>wavelength['aaa.ba'] (which also includes all wavelengths of all "subfiles" as well -- again in order).</p>
  
  <p>and so on. The filenames are well-behaved (the sections are separated by periods, the grouping hierarchy is always the same direction, etc.) but the files can be between 4 sections, or 8 sections long.</p>
  
  <p>My question: is there some sensible way to have python glob the names of the files and by parsing strings or some other magic get the data into these dictionaries? I've hit a brick wall.</p>