Woffee commited on
Commit
eee2284
·
1 Parent(s): a1e6a6c

Max to Now

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -16,27 +16,27 @@ def csv_to_dict(df):
16
  if row['CRN'] not in res:
17
  res[ row['CRN' ] ] = {
18
  'Instructor': row['Instructor'],
19
- 'Max': row['Max'],
20
  }
21
  return res
22
 
23
  def compare_dicts(dict_a, dict_b):
24
- # 遍历两个字典,查找Instructor或Max不同的CRN
25
  changed = []
26
  all_crns = set(dict_a.keys()).union(set(dict_b.keys()))
27
 
28
  for crn in all_crns:
29
  instructor_a = dict_a.get(crn, {}).get('Instructor', None)
30
  instructor_b = dict_b.get(crn, {}).get('Instructor', None)
31
- max_a = dict_a.get(crn, {}).get('Max', None)
32
- max_b = dict_b.get(crn, {}).get('Max', None)
33
 
34
  # 如果Instructor或Max不同,则记录CRN
35
  if instructor_a != instructor_b:
36
  msg = ' * CRN: {}, Instructor change: {} --> {}'.format(crn, instructor_a, instructor_b)
37
  changed.append(msg)
38
  if max_a != max_b:
39
- msg = ' * CRN: {}, Max change: {} --> {}'.format(crn, max_a, max_b)
40
  changed.append(msg)
41
 
42
  return changed
@@ -72,10 +72,10 @@ def process_files(files):
72
  # 使用Gradio构建界面
73
  gr.Interface(
74
  fn=process_files,
75
- inputs=gr.Files(label="Upload CCSV files"),
76
  outputs="text",
77
  title="Course Schedule Tracker",
78
- description="Upload multiple CSV files, sort them based on the timestamp in the filenames, compare two adjacent files at a time, and output the CRNs where the Instructor or Max has changed."
79
  ).launch()
80
 
81
 
 
16
  if row['CRN'] not in res:
17
  res[ row['CRN' ] ] = {
18
  'Instructor': row['Instructor'],
19
+ 'Now': row['Now'],
20
  }
21
  return res
22
 
23
  def compare_dicts(dict_a, dict_b):
24
+ # 遍历两个字典,查找 Instructor Now 不同的CRN
25
  changed = []
26
  all_crns = set(dict_a.keys()).union(set(dict_b.keys()))
27
 
28
  for crn in all_crns:
29
  instructor_a = dict_a.get(crn, {}).get('Instructor', None)
30
  instructor_b = dict_b.get(crn, {}).get('Instructor', None)
31
+ max_a = dict_a.get(crn, {}).get('Now', None)
32
+ max_b = dict_b.get(crn, {}).get('Now', None)
33
 
34
  # 如果Instructor或Max不同,则记录CRN
35
  if instructor_a != instructor_b:
36
  msg = ' * CRN: {}, Instructor change: {} --> {}'.format(crn, instructor_a, instructor_b)
37
  changed.append(msg)
38
  if max_a != max_b:
39
+ msg = ' * CRN: {}, Now change: {} --> {}'.format(crn, max_a, max_b)
40
  changed.append(msg)
41
 
42
  return changed
 
72
  # 使用Gradio构建界面
73
  gr.Interface(
74
  fn=process_files,
75
+ inputs=gr.Files(label="Upload CSV files"),
76
  outputs="text",
77
  title="Course Schedule Tracker",
78
+ description="Upload multiple CSV files, sort them based on the timestamp in the filenames, compare two adjacent files at a time, and output the CRNs where the 'Instructor' or 'Now' has changed."
79
  ).launch()
80
 
81