title: I have an input file that I am trying to build a dictionary from
body: <p>I have an input file that I am trying to build a data base from.  <br/>
  <strong>Each line looks like this:</strong>  <br/></p>
  
  <pre><code>Amy Shchumer, Trainwreck, I Feel Pretty, Snatched, Inside Amy Shchumer  
  Bill Hader,Inside Out,  Trainwreck, Tropic Thunder 
  </code></pre>
  
  <p>And so on.  <br/>
  The first string is an actor\actress, and then movies they played in.  <br/>
  The data isn't sorted and they are some trailing whitespaces.  <br/></p>
  
  <p><strong>I would like to create a dictionary that would look like this:</strong>  <br/>
  <code>{'Trainwreck': {'Amy Shchumer', 'Bill Hader'}}</code>  <br/>
  The key would be the movie, the values should be the actors in it, unified in a set data type.  <br/></p>
  
  <pre><code>def create_db():
     my_dict = {}
     raw_data = open('database.txt','r+') 
     for line in raw_data:
        lst1 = line.split(",") //to split by the commas 
        len_row = len(lst1)
        lst2 = list(lst1) 
        for j in range(1,len_row):
           my_dict[lst2[j]] = set([lst2[0]])
  print(my_dict)
  </code></pre>
  
  <p>It doesn't work... it doesn't solve the issue that when a key already exists then the actor should be unified in a set with the prev actor  <br/></p>
  
  <p><strong>Instead I end up with:</strong>  <br/>
  <code>'Trainwreck': {'Amy Shchumer'}, 'Inside Out': {'Bill Hader'}</code>  <br/></p>