Re: [OT] Bash help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Wed, Oct 25, 2017 at 12:08 PM, Robert Arkiletian <robark@xxxxxxxxx> wrote:
> On Wed, Oct 25, 2017 at 9:59 AM, Robert Arkiletian <robark@xxxxxxxxx> wrote:
>> On Wed, Oct 25, 2017 at 9:41 AM, Mark Haney <mark.haney@xxxxxxxxxxx> wrote:
>>> On 10/25/2017 12:33 PM, Robert Arkiletian wrote:
>>>>
>>>> here is a python solution
>>>> #!/usr/bin/python
>>>> #python 2 (did not check if it works)
>>>> f=open('yourfilename')
>>>> D={}
>>>> for line in f:
>>>>      email,num = line.split()
>>>>      if email in D:
>>
>>>>          D[email] = D[email] + int(num)
>>
>>>>      else:
>>
>>>>          D[email] = int(num)
>>
>>>> f.close()
>
> not to be outdone, python can sort them based on the totals
>
> for k in sorted(D, key=d.get, reverse=True):

oops. that's a capital D.get

 for k in sorted(D, key=D.get, reverse=True):

>     print k, D[k]
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
https://lists.centos.org/mailman/listinfo/centos



[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]


  Powered by Linux