Reassigning keys in dictionary of lists and then writing out to CSV file?

2015-06-18 Thread Sahlusar
I am currently attempting to work on converting a fairly sizeable JSON object and convert it into a CSV format. However, when I attempt to do so, using a conventional approach (that seems to work with other files). I am presented with a "ValueError: too many values to unpack" I have tried to fl

RE: Unable to lookup keys in dictionary

2008-08-12 Thread Matt Fielding (R* New England)
August 12, 2008 11:27 AM To: python-list@python.org Subject: Unable to lookup keys in dictionary I am trying to run p4python API on top of python 2.5.2 and am extracting a dictionary from perforce. The following code returns the output that follows it: from P4 import P4, P4Exception

Re: Unable to lookup keys in dictionary

2008-08-12 Thread Jerry Hill
On Tue, Aug 12, 2008 at 11:27 AM, Matt Fielding (R* New England) <[EMAIL PROTECTED]> wrote: > [{'userName': 'mfielding', 'clientRoot': 'c:\\perforce', 'monitor': > 'enabled', > 'serverRoot': 'H:\\p4root\\', 'serverVersion': 'P4D/NTX64/2007.3/143793 > (2008/01/ > 21)', 'serverDate': '2008/08/12 11:1

RE: Unable to lookup keys in dictionary

2008-08-12 Thread Andreas Tawn
>I am trying to run p4python API on top of python 2.5.2 and am extracting a dictionary from perforce. The following code returns the output that follows it: > > from P4 import P4, P4Exception > p4 = P4() > p4.port = "erased" #deleted > p4.us

Unable to lookup keys in dictionary

2008-08-12 Thread Matt Fielding (R* New England)
I am trying to run p4python API on top of python 2.5.2 and am extracting a dictionary from perforce. The following code returns the output that follows it: from P4 import P4, P4Exception p4 = P4() p4.port = "erased" #deleted p4.user = "erased" #deleted

Re: keys in dictionary

2005-11-22 Thread Georges Barthelemy
use (1,2) , (3,4) "Shi Mu" <[EMAIL PROTECTED]> a écrit dans le message de news: [EMAIL PROTECTED] I run the following code and got wrong message, but I still want to make [1,2],[4,3] and [6,9] to be keys of the dictionary or change the style a little bit. How to do that? Thanks! >>> p=[[1,

Re: keys in dictionary

2005-11-21 Thread Martin v. Löwis
Shi Mu wrote: > I run the following code and got wrong message, but I still want to > make [1,2],[4,3] and [6,9] to be keys of the dictionary or change the > style a little bit. How to do that? Make them tuples: >>> p=[[1,2],[4,3],[6,9]] >>> n=dict([(tuple(x),[]) for x in p]) >>> n {(6, 9): [

keys in dictionary

2005-11-21 Thread Shi Mu
I run the following code and got wrong message, but I still want to make [1,2],[4,3] and [6,9] to be keys of the dictionary or change the style a little bit. How to do that? Thanks! >>> p=[[1,2],[4,3],[6,9]] >>> n=dict([(x,[]) for x in p]) Traceback (most recent call last): File "", line 1, in ?

Re: how can i randomly choose keys in dictionary

2005-02-18 Thread John Lenton
On Fri, Feb 18, 2005 at 09:35:30AM +0100, Thomas Guettler wrote: > Am Thu, 17 Feb 2005 18:13:46 -0800 schrieb neutrinman: > > > Hi,there. How can I choose a key in dictionary randomly? > > > > Say, random.choice() in lists, > > > > or in lists: > > lists = [1,2,3,4] > > position = random.range(l

Re: how can i randomly choose keys in dictionary

2005-02-18 Thread Thomas Guettler
Am Thu, 17 Feb 2005 18:13:46 -0800 schrieb neutrinman: > Hi,there. How can I choose a key in dictionary randomly? > > Say, random.choice() in lists, > > or in lists: > lists = [1,2,3,4] > position = random.range(len(lists)) > word = lists[position] Hi, try this: import random mydict={1: "one"

RE: how can i randomly choose keys in dictionary

2005-02-17 Thread Tony Meyer
> Hi,there. How can I choose a key in dictionary randomly? > > Say, random.choice() in lists, A dictionary's keys() are a list, so you already have the answer: >>> import random >>> d = {'a': 1, 'b': 2, 'c': 3} >>> random.choice(d.keys()) =Tony.Meyer -- http://mail.python.org/mailman/listinfo

how can i randomly choose keys in dictionary

2005-02-17 Thread neutrinman
Hi,there. How can I choose a key in dictionary randomly? Say, random.choice() in lists, or in lists: lists = [1,2,3,4] position = random.range(len(lists)) word = lists[position] -- http://mail.python.org/mailman/listinfo/python-list