title: How to read a file block-wise in python
body: <p>I am bit stuck in reading a file block-wise, and facing difficulty in getting some selective data in each block :</p>
  
  <p>Here is my file content :</p>
  
  <pre><code>DATA.txt
  
  #-----FILE-----STARTS-----HERE--#
  #--COMMENTS CAN BE ADDED HERE--#
  
  BLOCK IMPULSE DATE 01-JAN-2010 6 DEHDUESO203028DJE \
      SEQUENCE=ai=0:at=221:ae=3:lu=100:lo=NNU:ei=1021055:lr=1: \
      USERID=ID=291821 NO_USERS=3 GROUP=ONE id_info=1021055 \
      CREATION_DATE=27-JUNE-2013 SN=1021055  KEY ="22WS \
      DE34 43RE ED54 GT65 HY67 AQ12 ES23 54CD 87BG 98VC \
      4325 BG56"
  
  BLOCK PASSION DATE 01-JAN-2010 6 DEHDUESO203028DJE \
      SEQUENCE=ai=0:at=221:ae=3:lu=100:lo=NNU:ei=324356:lr=1: \
      USERID=ID=291821 NO_USERS=1 GROUP=ONE id_info=324356 \
      CREATION_DATE=27-MAY-2012 SN=324356  KEY ="22WS \
      DE34 43RE 342E WSEW T54R HY67 TFRT 4ER4 WE23 XS21 \
      CD32 12QW"
  
  BLOCK VICTOR DATE 01-JAN-2010 6 DEHDUESO203028DJE \
      SEQUENCE=ai=0:at=221:ae=3:lu=100:lo=NNU:ei=324356:lr=1: \
      USERID=ID=291821 NO_USERS=5 GROUP=ONE id_info=324356 \
      CREATION_DATE=27-MAY-2012 SN=324356  KEY ="22WS \
      DE34 43RE 342E WSEW T54R HY67 TFRT 4ER4 WE23 XS21 \
      CD32 12QW"
  
  #--BLOCK--ENDS--HERE#
  #--NEW--BLOCKS--CAN--BE--APPENDED--HERE--#      
  </code></pre>
  
  <p>I am only interested in Block Name , NO_USERS, and id_info of each block .
  these three data to be saved to a data-structure(lets say dict), which is further stored in a list :</p>
  
  <pre><code>[{Name: IMPULSE ,NO_USER=3,id_info=1021055},{Name: PASSION ,NO_USER=1,id_info=324356}. . . ]
  </code></pre>
  
  <p>any other data structure which can hold the info would also be fine.</p>
  
  <p>So far i have tried getting the block names by reading line by line :</p>
  
  <pre><code>fOpen = open('DATA.txt')
  unique =[]
  for row in fOpen:
      if "BLOCK" in row:
          unique.append(row.split()[1])
  print unique
  </code></pre>
  
  <p>i am thinking of  regular expression approach, but i have no idea where to start with.
  Any help would be appreciate.Meanwhile i am also trying , will update if i get something . Please help .</p>