-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
47 lines (35 loc) · 1.21 KB
/
utils.py
File metadata and controls
47 lines (35 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import csv
def getScoutNames(data):
return list(set(d['scoutName'] for d in data))
def getLastMatchNum(data):
return max(map(lambda d: int(d['matchNum']), data))
def scoutingDataTo2dArray(data, lastMatchNum):
organized = [[] for _ in range(lastMatchNum)]
for scoutData in data:
organized[int(scoutData['matchNum']) - 1].append(scoutData)
return organized
def correctZerosAlliance(number):
if number != 0:
return number + 3
else:
return 0
def correctZerosScouting(allianceTotal, scouterData):
if allianceTotal != 0:
return scouterData + 1
else:
return scouterData
def correctZerosBothAlliances(number):
if number != 0:
return number + 6
else:
return 0
def exportToCSV(data, filename):
if not data:
print("No data to write.")
return
keys = data[0].keys() # Get column names from the first dictionary
with open(filename, 'w', newline='') as csvfile:
writer = csv.DictWriter(csvfile, fieldnames=keys)
writer.writeheader() # Write column names
writer.writerows(data) # Write rows
print(f"\nData successfully written to {filename}")