title: Text file processing in python
body: <p>I have the following file:</p>
  
  <pre><code>1    real madrid,barcelona,chelsea,arsenal,cska
  2    chelsea,arsenal,milan,napoli,juventus
  5    bayern,dortmund,celtic,napoli
  7    cska,psg,arsenal,atalanta
  9    atletic bilbao,las palmas,milan,barcelona
  </code></pre>
  
  <p>and I want to produce a new file with this output (where I had the nodes, now I have every team and in the second column I have the nodes that has this team as attribute):</p>
  
  <pre><code>real madrid    1
  barcelona    1,9
  chelsea    1,2
  arsenal    1,2,7
  cska    1,7
  milan    2,9
  etc...
  </code></pre>
  
  <p>First of all i opened the file and I saved each column to a list:</p>
  
  <pre><code>file1 = open("myfile.txt","r")
  lines1 = file1.readlines()
  nodes1 = []
  attrs1 = []
  
  
  for x in lines1:
      x = x.strip()
      x = x.split('\t')
      nodes1.append(x[0])
      attrs1.append(x[1].split(','))
  </code></pre>
  
  <p>but now how can I check the attrs and nodes to produce the output file?</p>