title: How can I split a text file with # as separator and then split the lines inside the separated part?
body: <p>I have a text file that have a pattern like</p>
  <pre><code>#
  a,b
  c,d
  #
  e,f
  g,h
  </code></pre>
  <p>I want the result to print as each block separated is an element and each line in the block is a sub-element to the block one</p>
  <p><code>[[[a, b], [c, d]], [[e, f], [g, h]]]</code></p>
  <p>Here is my code, any suggestion from here to get the result ? Thanks</p>
  <pre><code>    ret_list = []
  
      a = open(file_name,'r')
      content = a.read()
      content = content.split('#')
      for l in content:
          l = l.strip().split('\n')
          for elem in l:
              temp = []
              elem = elem.split(',')
              if '' not in elem:
                  temp.append(elem)
              ret_list.append(temp)
      
      a.close() 
  </code></pre>
  <p>And the result I got</p>
  <pre><code>[[], [['a', 'b']], [['c', 'd']], [['e', 'f']], [['g', 'h']]]
  </code></pre>