From: Benjamin Mako Hill Date: Thu, 8 Oct 2020 15:09:21 +0000 (-0700) Subject: read student information using DictReader X-Git-Url: https://code.communitydata.science/coldcallbot-discord.git/commitdiff_plain/f46f00dc4d9b4d592801971c1d35471251c29216?ds=inline read student information using DictReader This should be safer. --- diff --git a/coldcall.py b/coldcall.py index 8cae6ca..2b5b5d8 100644 --- a/coldcall.py +++ b/coldcall.py @@ -38,12 +38,8 @@ class ColdCall(): preferred_names = {} with open(self.__fn_studentinfo, 'r') as f: - for line in f.readlines(): - x = line.strip().split("\t") - if x[0] == "Timestamp": - continue - - preferred_names[x[4]] = x[2] + for row in DictReader(f, delimiter="\t"): + preferred_names[row["Your username on the class Discord server"]] = row["Name you'd like to go by in class"] if selected_student in preferred_names: return preferred_names[selected_student] @@ -103,12 +99,12 @@ class ColdCall(): return coldcall_message # cc = ColdCall() + +# test_student_list = ["jordan", "Kristen Larrick", "Madison Heisterman", "Maria.Au20", "Laura (Alia) Levi", "Leona Aklipi", "Linya Feng", "anne", "kirst", "emmaaitelli", "ashleylee", "allie_partridge", "Tiana_Cole", "Hamin", "Ella Qu", "Angel Su", "Shizuka", "Ben Baird", "Kim Do", "Isaacm24", "Sam Bell", "Courtneylg", "TasnimHasan"] +# print(cc.coldcall(test_student_list)) -# test_student_list = ["Jordan", "Kristen Larrick", "Madison Heisterman", "Maria.Au20", "Laura (Alia) Levi", "Leona Aklipi", "Linya Feng", "anne", "kirst", "emmaaitelli", "ashleylee", "allie_partridge", "Tiana_Cole", "Hamin", "Ella Qu", "Angel Su", "Shizuka", "Ben Baird", "Kim Do", "Isaacm24", "Sam Bell", "Courtneylg", "TasnimHasan"] -# cc.coldcall(test_student_list) - -# test_student_list = ["Jordan", "Kristen Larrick", "Mako"] -# cc.coldcall(test_student_list) +# test_student_list = ["jordan", "Kristen Larrick", "Mako"] +# print(cc.coldcall(test_student_list)) -# test_student_list = ["Jordan", "Kristen Larrick"] -# cc.coldcall(test_student_list) +# test_student_list = ["jordan", "Kristen Larrick"] +# print(cc.coldcall(test_student_list))