1234567891011121314151617181920212223242526272829303132333435 |
- """
- Calculate percentage level of index for regions
- inside the Verenigde Nederlanden.
- """
- import re
- PLAYERS = {}
- def calculate_buildings():
- """Count working in departments"""
- with open('department.txt', 'r') as file:
- for line in file:
- line = re.sub(r'\s\d\d.*', '', line)
- line = re.sub(r'\[.*\]', '', line)
- line = line.strip()
- try:
- count = re.search(r'\+\d+', line).group(0)
- count = count.replace('+', '')
- player = re.sub(r'\s\(.*', '', line)
- if player in PLAYERS:
- PLAYERS[player] += int(count)
- else:
- PLAYERS[player] = 1
- except Exception as exception:
- print('%s %s' % (line, exception))
- for player in sorted(PLAYERS, key=PLAYERS.get, reverse=True):
- print('%3s %s' % (PLAYERS[player], player))
- if __name__ == '__main__':
- calculate_buildings()
|