-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d4c9122
commit 2612db3
Showing
1 changed file
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import csv | ||
|
||
def team_conversations(): | ||
total = {'proteus': 0, 'mixed': 0, 'mls': 0} | ||
teams = {} | ||
with open('conv-group-team-protocol.csv') as csv_file: | ||
csv_reader = csv.DictReader(csv_file, delimiter=',') | ||
|
||
for row in csv_reader: | ||
team = row['team'] | ||
protocol = row['protocol'] | ||
|
||
if protocol not in ['proteus', 'mixed', 'mls']: | ||
protocol = 'proteus' | ||
if protocol not in total: | ||
total[protocol] = 0 | ||
if team not in teams: | ||
teams[team] = {'proteus': 0, 'mixed': 0, 'mls': 0} | ||
|
||
total[protocol] += 1 | ||
teams[team][protocol] += 1 | ||
|
||
for name, team in teams.values(): | ||
proteus = team['proteus'] | ||
mixed = team['mixed'] | ||
mls = team['mls'] | ||
print(f'In team {name}, conversations ' + | ||
f'in Proteus are {proteus}, ' + | ||
f'in Mixed are {mixed}, and ' + | ||
f'in MLS are {mls}.') | ||
|
||
proteus = total['proteus'] | ||
mixed = total['mixed'] | ||
mls = total['mls'] | ||
print(f'In total, conversations in Proteus are {proteus}, '+ | ||
f'in Mixed are {mixed}, and in MLS are {mls}.') | ||
|
||
def conversation_clients(): | ||
with open('conv-group-team-protocol.csv') as csv_file: | ||
conv = {} | ||
csv_reader = csv.DictReader(csv_file, delimiter=',') | ||
for row in csv_reader: | ||
conv[row['group']] = row['conversation'] | ||
|
||
with open('domain-user-client-group.csv') as csv_file: | ||
mls_clients = {} | ||
csv_reader = csv.DictReader(csv_file, delimiter=',') | ||
for row in csv_reader: | ||
group = row['group'] | ||
if group in conv: | ||
conversation = conv[group] | ||
user = row['user'] | ||
if conversation not in mls_clients or user not in mls_clients[conversation]: | ||
mls_clients[conversation] = {user: 0} | ||
mls_clients[conversation][user] += 1 | ||
|
||
with open('user-client.csv') as csv_file: | ||
user_clients = {} | ||
csv_reader = csv.DictReader(csv_file, delimiter=',') | ||
for row in csv_reader: | ||
user = row['user'] | ||
if user not in user_clients: | ||
user_clients[user] = 0 | ||
user_clients[user] += 1 | ||
|
||
with open('user-conv.csv') as csv_file: | ||
conv_clients = {} | ||
csv_reader = csv.DictReader(csv_file, delimiter=',') | ||
for row in csv_reader: | ||
user = row['user'] | ||
conversation = row['conversation'] | ||
if conversation not in conv_clients: | ||
conv_clients[conversation] = {'proteus': 0, 'mls': 0} | ||
if conversation in mls_clients and user in mls_clients[conversation]: | ||
mls = mls_clients[conversation][user] | ||
else: | ||
mls = 0 | ||
if user in user_clients: | ||
proteus = user_clients[user] - mls | ||
else: | ||
proteus = 0 | ||
conv_clients[conversation]['proteus'] += proteus | ||
conv_clients[conversation]['mls'] += mls | ||
|
||
for name, conversation in conv_clients.items(): | ||
proteus = conversation['proteus'] | ||
proteus = conversation['mls'] | ||
print(f'In conversation {name}, there are ' + | ||
f'{proteus} Proteus clients and {mls} MLS clients.') |