Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
merge changes from another copy for xlsx. rename _old to _html.
  • Loading branch information
Jerry Shi committed Dec 21, 2023
1 parent feb0e56 commit 72d25ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
File renamed without changes.
18 changes: 14 additions & 4 deletions cleanup-roster.py
Expand Up @@ -27,8 +27,9 @@ def is_hot_major(m, checksecond = False):

def get_major_from_program(prog):
# m = re.findall(r"(?: -|/)([^/]+)", prog)

majors = re.search("_x000D_(.+)", prog)
# majors = re.search("_x000D_(.+)", prog)
majors = re.search(r" -\s+(.+)", prog)
# print(prog)
assert majors is not None
# print(majors.group())

Expand Down Expand Up @@ -82,6 +83,9 @@ class Students:
m = [ c.value for c in row ]
self.student_list.append(m)

def get_field_list(self):
return self.field_list

def __iter__(self):
self.idx = 0
return self
Expand Down Expand Up @@ -149,10 +153,11 @@ def load_file(file, students):
return True

parser = argparse.ArgumentParser(description='Clean up downloaded roster from HuskyCT. April 2023.')
parser.add_argument('infiles', nargs='*', default=[], help='Input files.')
parser.add_argument('infiles', nargs='+', default=[], help='Input files. Can have multiple files.')
parser.add_argument('-o', nargs='?', default='', const='', help='Output file.')
parser.add_argument('-f', nargs='+', default=[], help='Add the list of fields to the default list')
parser.add_argument('--fields', nargs='+', default=[], help='Set the list of fields to print.')
parser.add_argument('--listfields', action='store_true', help='List fields.')
parser.add_argument("-v", action='count', default=0, help='Verbose level.')

args = parser.parse_args()
Expand All @@ -168,7 +173,12 @@ students = Students()

for file in args.infiles:
logging.info(f"Loading from {file}...")
load_file(file, students)
if not load_file(file, students):
exit(1)

if args.listfields:
print(students.get_field_list())
exit(0)

students.set_major()
students.set_fields(args.fields)
Expand Down

0 comments on commit 72d25ef

Please sign in to comment.