Re: besoin d'aide pour bach ou autre

Top Page

Reply to this message
Author: Jérôme Kieffer
Date:  
To: guilde
Subject: Re: besoin d'aide pour bach ou autre

En Python:
```
#!/usr/bin/python3
import sys

with open(sys.argv[1], "rt") as f:
    raw = [i.strip() for i in f.readlines()]


count = {}
for line in raw:
    words = line.split(";")
    if len(words)<2:
        continue
    second = words[1]
    if second in count:
        count[second] += 1
    else:
        count[second] = 1
for line in raw:
    words = line.split(";")
    if len(words)<2:
        print(line)
    else:
        print(line+";"+str(count[words[1]]))


```