Created
January 25, 2021 19:34
-
-
Save bonheml/a86365f33592c9add5df44d023d44b65 to your computer and use it in GitHub Desktop.
A small python script to parse Teams attendance file. Requires pandas.
This file contains hidden or 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
import pandas as pd | |
import argparse | |
parser = argparse.ArgumentParser() | |
parser.add_argument("--attendance", "-a", type=str, required=True, help="A Teams attendance file") | |
parser.add_argument("--output", "-o", type=str, help="An output file name, if not provided output will only be displayed") | |
parser.add_argument("--teachers", "-t", metavar='T', type=str, nargs='+', | |
help="Names of the class supervisors attending the class", default=[]) | |
def main(args): | |
df = pd.read_csv(args.attendance, sep="\t", encoding="UTF-16") | |
names = [n.split(" ", 1) for n in df["Full Name"].unique() if n not in args.teachers] | |
df = pd.DataFrame(names, columns=["First Name", "Last Name"]) | |
df = df[["Last Name", "First Name"]].sort_values(by=["Last Name"]).reset_index(drop=True) | |
df.index += 1 | |
if args.output: | |
df.to_csv(args.output, index=False, sep="\t") | |
print(df) | |
if __name__ == "__main__": | |
args = parser.parse_args() | |
main(args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment