title: Get the file hierarchy of a directory by the file path with Python
body: <p>Here is my question. I used os.walk to get all the file paths under a specific directory and stored the path in a file like this</p>
  
  <pre><code>/indexes/attachment/CCTBAU/CCTBAU-13/87009
  /indexes/attachment/CCTBAU/CCTBAU-19/91961
  /indexes/attachment/CCTBAU/CCTBAU-19/thumbs/_thumb_91961.png
  /indexes/attachment/CCTBAU/CCTBAU-11/86413
  /indexes/attachment/CCTBAU/CCTBAU-11/thumbs/_thumb_86412.png
  /indexes/attachment/CCTBAU/CCTBAU-11/thumbs/_thumb_86413.png
  /indexes/attachment/CCTBAU/CCTBAU-12/86614
  /indexes/attachment/CCTBAU/CCTBAU-16/90240
  /indexes/attachment/CCTBAU/CCTBAU-17/90241
  /indexes/attachment/ACD/ACD-200/91345
  /indexes/attachment/ACD/ACD-200/96305
  /indexes/attachment/ACD/ACD-200/99169
  /indexes/attachment/ACD/ACD-201/91344
  /indexes/attachment/ACD/ACD-202/91346
  /indexes/attachment/ACD/ACD-197/88916
  /indexes/attachment/ACD/ACD-189/73799
  /indexes/attachment/ACD/ACD-38/60709
  /indexes/attachment/ACD/ACD-198/88918
  </code></pre>
  
  <p>Now, I want to get the file hierarchy by reading all paths in the file, which means that I read the file and get all the paths, then I can know the file hierarchy is </p>
  
  <pre><code>index
    |--attachment
           |-----ACD
           |      |---ACD-200
           |      |---...
           |
           |-----CCTBAU
                  |----CCTBAU-13
                  |----...
  </code></pre>
  
  <p>Who can help out of this? Thanks in advance!</p>