Thanks again I have worked that issue out.

However I have the following function and it is throwing this error:

FEXpython_v2.py", line 32, in UnitHolderDistributionqty
    count[item]+=1
KeyError: 3

This is the function:

def Distributionqty(dictionary):
    holder=list()
    held=list()
    distqtydic={}
    count={}
    for key in sorted(dictionary.keys()):
        holder.append(key)
        held.append(len(dictionary[key]))
    for (key, value) in map(None, holder, held):
        distqtydic[key]=value
    for item in distqtydic.values():
        count[item]+=1
    for k,v in sorted(count.items()):
        fdist=k
        qty=v
        print fdist,qty

Not sure...

M.



On 10/1/07, Kent Johnson <[EMAIL PROTECTED]> wrote:
>
> GTXY20 wrote:
> >
> > This works perfectly.
> >
> > However I will be dealing with an import of a very large dictionary - if
>
> > I call the commands at command line this seems to be very taxing on the
> > CPU and memory and will take a long time.
> >
> > I was thinking of creating each as a fucntion whereby python would just
> > to write to a file instead of calling within a python shell do you think
> > that this would speed up the process?
>
> I don't understand what you are suggesting.
>
> Both of your requirements just need the values of the dict. If the dict
> is being created from a file, you could probably build the count dicts
> on the fly as you read the values without ever creating the dict with
> all the items in it.
>
> Kent
>
> >
> > All in total I will probably be looking at about 2 million dictionary
> > keys with assorted value quantities.
>
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to