i have a large string like
res = ["FAV_VENUE_CITY_NAME == 'Mumbai' & EVENT_GENRE == 'KIDS' & count_EVENT_GENRE >= 1",
"FAV_VENUE_CITY_NAME == 'Mumbai' & EVENT_GENRE == 'FANTASY' & count_EVENT_GENRE >= 1",
"FAV_VENUE_CITY_NAME =='Mumbai' & EVENT_GENRE == 'FESTIVAL' & count_EVENT_GENRE >= 1",
"FAV_VENUE_CITY_NAME == 'New Delhi' & EVENT_GENRE == 'WORKSHOP' & count_EVENT_GENRE >= 1",
"FAV_VENUE_CITY_NAME == 'Mumbai' & EVENT_GENRE == 'EXHIBITION' & count_EVENT_GENRE >= 1",
"FAV_VENUE_CITY_NAME == 'Bangalore' & FAV_GENRE == '|DRAMA|'",
"FAV_VENUE_CITY_NAME = 'Mumbai' & & FAV_GENRE == '|ACTION|ADVENTURE|SCI-FI|'",
"FAV_VENUE_CITY_NAME == 'Bangalore' & FAV_GENRE == '|COMEDY|'",
"FAV_VENUE_CITY_NAME == 'Bangalore' & FAV_GENRE == 'DRAMA' & FAV_LANGUAGE == 'English'",
"FAV_VENUE_CITY_NAME == 'New Delhi' & FAV_LANGUAGE == 'Hindi' & count_EVENT_LANGUAGE >= 1"]
now i am extracting fields by
res = [re.split(r'[(==)(>=)]', x)[0].strip() for x in re.split('[&($#$)]', whereFields)]
res = [x for x in list(set(res)) if x]
o/p:['FAV_GENRE', 'FAV_LANGUAGE', 'FAV_VENUE_CITY_NAME', 'count_EVENT_GENRE', 'EVENT_GENRE','count_EVENT_LANGUAGE']
then by following this filter out some items from a list and store in different arrays in python
i am getting values
FAV_VENUE_CITY_NAME = ['New Delhi', 'Mumbai', 'Bangalore']
FAV_GENRE = ['|DRAMA|', '|COMEDY|', '|ACTION|ADVENTURE|SCI-FI|', 'DRAMA']
EVENT_GENRE = ['FESTIVAL', 'WORKSHOP', 'FANTASY', 'KIDS', 'EXHIBITION']
FAV_LANGUAGE = ['English', 'Hindi']
count_on_field = ['EVENT_GENRE', 'EVENT_LANGUAGE']
Now i want to make a dictionary whose key will be field name in res. and values will be the result from above link.
Or is there a way to make items of list res as different different list by themselves.
SOmething like
res = ['FAV_GENRE', 'FAV_LANGUAGE', 'FAV_VENUE_CITY_NAME', 'count_EVENT_GENRE', 'EVENT_GENRE','count_EVENT_LANGUAGE']
for i in range(len(res)):
res[i] = list(res[i]) # make each item as an empty list with name as it is
so that they become like
FAV_VENUE_CITY_NAME = []
EVENT_GENRE = []
FAV_GENRE = []
FAV_LANGUAGE = [
then get the value to each individual lists in res list by following the method in above link.
Then make a dictionary like the below line making a dict with index as key
a = [51,27,13,56]
b = dict(enumerate(a))
#####d = dict{key=each list name from res list, value = value in each ind. lists}
#
or if possible suggest something like from top res list....how to form a dict having key as field names and values as values from each lines
o/p: d = {'FAV_VENUE_CITY_NAME':['Mumbai','New Delhi','Bangalore'], 'EVENT_GENRE':['KIDS','FANTASY','FESTIVAL','WORKSHOP','EXHIBITION'], 'FAV_GENRE':['|DRAMA|','|ACTION|ADVENTURE|SCI-FI|','|COMEDY|','DRAMA'], 'FAV_LANGUAGE':['English','Hindi']}
count_EVENT_GENRE>=1,count_EVENT_LANGUAGE>=1 should not be in that dictionary ,rather they should go to a list
count_on_fields = ['EVENT_GENRE','EVENT_LANGUAGE']
Pease if anybody has a better idea or suggestion, do help.