Skip to content

Instantly share code, notes, and snippets.

@bonheml
Created January 25, 2021 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bonheml/a86365f33592c9add5df44d023d44b65 to your computer and use it in GitHub Desktop.
Save bonheml/a86365f33592c9add5df44d023d44b65 to your computer and use it in GitHub Desktop.
A small python script to parse Teams attendance file. Requires pandas.
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