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

Problem adding a Key Value pair

2014-11-04 Thread Anurag Patibandla
I am trying to add a key value pair of ("Priority":"1") to queue1, ("Priority":"2") to queue2, and ("Priority":"3") to queue3. When I just add ("Priority":"1") to queue1, it works. But when I run the above code, ("Priority":"3") is being added to all the queues. This looks trivial and I don't

Re: Problem adding a Key Value pair

2014-11-04 Thread Anurag Patibandla
On Tuesday, November 4, 2014 2:37:49 PM UTC-5, Anurag Patibandla wrote: > I am trying to add a key value pair of ("Priority":"1") to queue1, > ("Priority":"2") to queue2, and ("Priority":"3") to queue3. > When I just add (

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"}, > >

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 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 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-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-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 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 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 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(roun

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: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 = {"

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.