You could use str.split
to deal with strings. First split each element string with '('
, with maxsplit being 1:
In [48]: dic=dict(e[:-1].split('(', 1) for e in entities) #using [:-1] to filter out ')'
...: print dic
...:
{'#5= IFCAPPLICATION': "#1,'2014','Autodesk Revit 2014 (ENU)','Revit')", '#1= IFCORGANIZATION': "$,'Autodesk Revit 2014 (ENU)',$,$,$)"}
then split each value in the dict with ','
:
In [55]: dic={k: dic[k][:-1].split(',') for k in dic}
...: print dic
{'#5= IFCAPPLICATION': ['#1', "'2014'", "'Autodesk Revit 2014 (ENU)'", "'Revit'"], '#1= IFCORGANIZATION': ['$', "'Autodesk Revit 2014 (ENU)'", '$', '$', '$']}
Note that the key-value pairs in a dict is unordered, as you may see '#1= IFCORGANIZATION'
is not showing in the first place.