title: Retrieve specific lines from text file and use them to make a dictionary
body: <p>I want to create a dictionary using certain lines in a textfile. Here an examples from my textfile (each 'page' is separated by '//'):</p>
  
  <pre><code>//
  UNIQUE-ID - INDOLE-3-ACETYL-BETA-4-D-GLUCOSE
  TYPES - Compounds
  COMMON-NAME - 4-&lt;i&gt;O&lt;/i&gt;-(indol-3-ylacetyl)-&amp;beta;-D-glucose
  DBLINKS - (HMDB "HMDB12213" NIL |kothari| 3594494404 NIL NIL)
  INCHI - InChI=1S/C16H19NO7/c18-7-11-15(13(20)14(21)16(22)23-11)24-12(19)5-8-6-17-10-4-2-1-3-9(8)10/h1-4,6,11,13-18,20-22H,5,7H2/t11-,13-,14-,15-,16-/m1/s1
  SMILES - C(C3(C(OC(=O)CC1(=CNC2(C=CC=CC1=2)))C(O)C(O)C(O)O3))O
  SYNONYMS - indole-3-acetyl-&amp;beta;-4-D-glucose
  //
  UNIQUE-ID - CPD-6783
  TYPES - Myo-inositol-bisphosphates
  COMMON-NAME - D-&lt;i&gt;myo&lt;/i&gt;-inositol (2,4) bisphosphate
  DBLINKS - (HMDB "HMDB03905" NIL |kothari| 3608597114 NIL NIL)
  DBLINKS - (PUBCHEM "25245743" NIL |taltman| 3466375284 NIL NIL)
  INCHI - InChI=1S/C6H14O12P2/c7-1-2(8)5(17-19(11,12)13)4(10)6(3(1)9)18-20(14,15)16/h1-10H,(H2,11,12,13)(H2,14,15,16)/p-4/t1-,2-,3+,4-,5-,6-/m0/s1
  //
  </code></pre>
  
  <p>The dictionary should have the line starting with 'INCHI - InChI=' as a key and the line containg 'DBLINKS - (HMDB' as the value. And here is my code:</p>
  
  <pre><code>data = open('compounds.dat', 'r', errors = 'ignore')
  compounds = data.readlines()
  
  INCHI_list = []
  HMDB_list = []
  dict_Inchi_HMDB = dict()
  
  for i,line in enumerate(compounds):
      if 'INCHI - InChI=' in line:
          INCHI_list.append(line)
  
      if 'DBLINKS - (HMDB' in line:
          HMDB_list.append(line)
  dict_Inchi_HMDB[INCHI_list] = HMDB_list
  </code></pre>
  
  <p>Which gives me the error unhashable type: 'list'. I understand why I get the error but I wasnt able to come up with a better approach... Could somebody help?</p>
  
  <p>Note that: 'DBLINKS - (HMDB' always comes before 'INCHI - InChI=' but the number of lines in between might vary. Also, the datafile contains several hundreds of these examples. And  the line 'DBLINKS - (HMDB' is not present in each 'page'</p>