Re: Parsing Python dictionary with multiple objects

2014-11-03 Thread Anurag Patibandla
json_split = {} value = {"Status": "Submitted", "m_Controller": "Python"} a = range(31) del a[0] for i in a: json_split[i] = value keys = json_split.keys() order = list(keys) q1 = int(round(len(keys)*0.2)) q2 = int(round(len(keys)*0.3)) q3 = int(round(len(keys)*0.5)) b = [q1,q2,q3] n=0 threedic

Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Dave Angel
Anurag Patibandla Wrote in message: > On Wednesday, October 15, 2014 1:35:43 PM UTC-4, Rustom Mody wrote: >> On Wednesday, October 15, 2014 10:51:11 PM UTC+5:30, Anurag Patibandla wrote: >> >> > Here is my sample dict if that helps: >> >> > >> >> > >> >> > >> >> > json = {"1": {"Status": "

Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Anurag Patibandla
On Wednesday, October 15, 2014 1:41:13 PM UTC-4, Dave Angel wrote: > Anurag Patibandla Wrote in message: > > > Thanks for the response. > > > Here is the code that I have tried. > > > > > > from operator import itemgetter > > > keys = json.keys() > > > order = list(keys) > > > q1 = int(rou

Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Anurag Patibandla
On Wednesday, October 15, 2014 1:35:43 PM UTC-4, Rustom Mody wrote: > On Wednesday, October 15, 2014 10:51:11 PM UTC+5:30, Anurag Patibandla wrote: > > > Here is my sample dict if that helps: > > > > > > > > > > > > json = {"1": {"Status": "Submitted", "Startdate": ["01/01/2011"], > > "End

Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Dave Angel
Anurag Patibandla Wrote in message: > dicts = dict(lists) > print dicts > print dict[0] > > Print dicts works as expected giving me the combine dictionary values. But > when I say dict[0]. I see the error: > TypeError: 'type' object has no attribute '__getitem__' > Of course. You

Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Dave Angel
Anurag Patibandla Wrote in message: > On Wednesday, October 15, 2014 1:10:41 PM UTC-4, Rustom Mody wrote: >> On Wednesday, October 15, 2014 10:30:49 PM UTC+5:30, Anurag Patibandla wrote: >> >> > keys = json.keys() >> >> > order = list(keys) >> >> > q1 = int(round(len(keys)*0.2)) >> >> > q2 = i

Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Dave Angel
Anurag Patibandla Wrote in message: > Thanks for the response. > Here is the code that I have tried. > > from operator import itemgetter > keys = json.keys() > order = list(keys) > q1 = int(round(len(keys)*0.2)) > q2 = int(round(len(keys)*0.3)) > q3 = int(round(len(keys)*0.5)) > b = [q1,q2,q3] >

Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Rustom Mody
On Wednesday, October 15, 2014 10:51:11 PM UTC+5:30, Anurag Patibandla wrote: > Here is my sample dict if that helps: > > > > json = {"1": {"Status": "Submitted", "Startdate": ["01/01/2011"], "Enddate": > ["02/02/2012"], "Job_ID": 1, "m_Quantile": "80", "m_Controller": "Python", > "m_Method":

Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Anurag Patibandla
Here is my sample dict if that helps: json = {"1": {"Status": "Submitted", "Startdate": ["01/01/2011"], "Enddate": ["02/02/2012"], "Job_ID": 1, "m_Quantile": "80", "m_Controller": "Python", "m_Method": "Distributed", "Allocation_3": ["50"], "Allocation_2": ["30"], "Allocation_1": ["20"], "Note"

Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Anurag Patibandla
On Wednesday, October 15, 2014 1:10:41 PM UTC-4, Rustom Mody wrote: > On Wednesday, October 15, 2014 10:30:49 PM UTC+5:30, Anurag Patibandla wrote: > > > keys = json.keys() > > > order = list(keys) > > > q1 = int(round(len(keys)*0.2)) > > > q2 = int(round(len(keys)*0.3)) > > > q3 = int(round(l

Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Rustom Mody
On Wednesday, October 15, 2014 10:30:49 PM UTC+5:30, Anurag Patibandla wrote: > keys = json.keys() > order = list(keys) > q1 = int(round(len(keys)*0.2)) > q2 = int(round(len(keys)*0.3)) > q3 = int(round(len(keys)*0.5)) > b = [q1,q2,q3] > n=0 > for i in b: > queues = order[n:n+i] > n = n+i

Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Anurag Patibandla
keys = json.keys() order = list(keys) q1 = int(round(len(keys)*0.2)) q2 = int(round(len(keys)*0.3)) q3 = int(round(len(keys)*0.5)) b = [q1,q2,q3] n=0 for i in b: queues = order[n:n+i] n = n+i lists = [(queues[j], json.get(queues[j])) for j in range(len(queues))] dicts

Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Rustom Mody
On Wednesday, October 15, 2014 10:13:18 PM UTC+5:30, Rustom Mody wrote: > On Wednesday, October 15, 2014 9:58:49 PM UTC+5:30, Anurag Patibandla wrote: > > First the values printed by > > '[(queues[j], json.get(queues[j])) for j in range(len(queues))] ' > > is a list, so I tried to convert it into a

Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Anurag Patibandla
keys = json.keys() order = list(keys) q1 = int(round(len(keys)*0.2)) q2 = int(round(len(keys)*0.3)) q3 = int(round(len(keys)*0.5)) b = [q1,q2,q3] n=0 for i in b: queues = order[n:n+i] n = n+i #print queues #print [(queues[j], json.get(queues[j])) for j in range(len(queues))

Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Rustom Mody
On Wednesday, October 15, 2014 9:58:49 PM UTC+5:30, Anurag Patibandla wrote: > First the values printed by > '[(queues[j], json.get(queues[j])) for j in range(len(queues))] ' > is a list, so I tried to convert it into a dict using dict(). > And then I tried doing dict[0] but there is an error which

Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Anurag Patibandla
First the values printed by '[(queues[j], json.get(queues[j])) for j in range(len(queues))] ' is a list, so I tried to convert it into a dict using dict(). And then I tried doing dict[0] but there is an error which says: 'type' object has no attribute '__getitem__' -- https://mail.python.org/mail

Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Rustom Mody
On Wednesday, October 15, 2014 9:22:48 PM UTC+5:30, Anurag Patibandla wrote: > Thanks Rustom for the advice. > I am new to Python and getting struck at some basic things. How do I assign > the values that I am printing to 3 variables say dict1, dict2, dict3? > When I try to assign them before the

Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Anurag Patibandla
Thanks Rustom for the advice. I am new to Python and getting struck at some basic things. How do I assign the values that I am printing to 3 variables say dict1, dict2, dict3? When I try to assign them before the print statement like this: d1, d2, d3 =[(queues[j], json.get(queues[j])) for j in ran

Re: Parsing Python dictionary with multiple objects

2014-10-14 Thread Rustom Mody
On Wednesday, October 15, 2014 9:10:54 AM UTC+5:30, Anurag Patibandla wrote: > Thanks for the response. > Here is the code that I have tried. > from operator import itemgetter > keys = json.keys() > order = list(keys) > q1 = int(round(len(keys)*0.2)) > q2 = int(round(len(keys)*0.3)) > q3 = int(rou

Re: Parsing Python dictionary with multiple objects

2014-10-14 Thread Anurag Patibandla
'json' has my original larger dict -- https://mail.python.org/mailman/listinfo/python-list

Re: Parsing Python dictionary with multiple objects

2014-10-14 Thread Anurag Patibandla
Thanks for the response. Here is the code that I have tried. from operator import itemgetter keys = json.keys() order = list(keys) q1 = int(round(len(keys)*0.2)) q2 = int(round(len(keys)*0.3)) q3 = int(round(len(keys)*0.5)) b = [q1,q2,q3] n=0 for i in b: queues = order[n:n+i] n =

Re: Parsing Python dictionary with multiple objects

2014-10-14 Thread Rustom Mody
On Wednesday, October 15, 2014 7:35:18 AM UTC+5:30, Dave Angel wrote: > anurag Wrote in message: > > I have a dictionary that looks like this: > > {"1":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, > > "2":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, > > "3":{"Key1":"Value1", "Key2

Re: Parsing Python dictionary with multiple objects

2014-10-14 Thread MRAB
On 2014-10-14 22:15, Anurag Patibandla wrote: On Tuesday, October 14, 2014 12:59:27 PM UTC-4, Dave Angel wrote: anuragpatiband...@gmail.com Wrote in message: > I have a dictionary that looks like this: > {"1":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, > "2":{"Key1":"Value1", "Key2":"V

Re: Parsing Python dictionary with multiple objects

2014-10-14 Thread Anurag Patibandla
On Tuesday, October 14, 2014 5:33:01 PM UTC-4, Skip Montanaro wrote: > Shuffle the keys, then grab the first 20 for one dictionary, the next 30 for > the second, and the last 50 for the third. > > Skip Could you please be more specific? -- https://mail.python.org/mailman/listinfo/python-list

Re: Parsing Python dictionary with multiple objects

2014-10-14 Thread Skip Montanaro
Shuffle the keys, then grab the first 20 for one dictionary, the next 30 for the second, and the last 50 for the third. Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: Parsing Python dictionary with multiple objects

2014-10-14 Thread Anurag Patibandla
On Tuesday, October 14, 2014 12:59:27 PM UTC-4, Dave Angel wrote: > anuragpatiband...@gmail.com Wrote in message: > > > I have a dictionary that looks like this: > > > {"1":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, > > > "2":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, > >