-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.py
84 lines (57 loc) · 1.98 KB
/
generate.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import pandas as pd
import os, json
# read students.json
f = open('students.json')
students = json.load(f)
paths = [
{'name': 'Class 1', 'path': 'Week_01'},
{'name': 'Class 2', 'path': 'Week_02'},
{'name': 'Class 2.5', 'path': 'Week_02.5'},
]
def getMeetingInfo(path):
# read and get meetingInfo
meetingInfo = pd.read_csv(path, nrows=1)
meetingInfo = meetingInfo.to_dict('records')[0]
print(meetingInfo)
return meetingInfo
def getParticipants(path):
# read csv
# skip lines 0, 1, 2
# only use columns 0 (Name) & 2 (Duration)
df = pd.read_csv(path, skiprows=[0,1,2], usecols=[0,2])
# rename columns
df.rename(columns={"Name (Original Name)":"name", "Total Duration (Minutes)":"duration"},inplace=True)
# convert df to dict
participants = df.to_dict('records')
for p in participants:
p['name'] = p['name'].replace("#", ",")
a = p['name'].partition(" (") # partition always returns array[3]
if (a[2]):
p['name'] = a[0]
p['alias'] = a[2].strip(")")
print(participants)
return participants
for p in paths:
folderName = os.path.join("ZoomReports", p['path'])
fileNames = os.listdir(folderName)
for fileName in fileNames:
if not fileName.startswith("."):
csv = os.path.join(folderName, fileName)
print(csv)
print("\n")
meetingInfo = getMeetingInfo(csv)
participants = getParticipants(csv)
#df = rawDF[1:2]
#df.columns = rawDF[:1].values[0] # add header from row 0
#df.reset_index(drop=True, inplace=True)
#meetingDF = df.loc[:, df.columns.notna()] # remove cols with NaN as name
#print(meetingDF)
#df = rawDF[3:]
#df.columns = rawDF[2:3].values[0]
#df = df.loc[:, df.columns.notna()] # remove cols with NaN as name
#df.drop(columns=['User Email', 'Guest'], inplace=True)
#df.rename(columns={"Name (Original Name)":"Name", "Total Duration (Minutes)":"Duration"}, inplace=True)
#df.reset_index(drop=True, inplace=True)
#df.Name = df.Name.str.replace('#', ',')
#df.Name.str.split(" ")
#print(df)