From 0fac08aebfbf0d8e6e03751017fbed90b134fec6 Mon Sep 17 00:00:00 2001 From: Aidan Haas <94150901+ahaas25@users.noreply.github.com> Date: Thu, 26 Jan 2023 13:34:43 -0500 Subject: [PATCH] Initial commit --- __pycache__/classes.cpython-39.pyc | Bin 0 -> 479 bytes __pycache__/constants.cpython-39.pyc | Bin 0 -> 246 bytes classes.py | 5 +++ constants.py | 5 +++ main.py | 63 +++++++++++++++++++++++++++ 5 files changed, 73 insertions(+) create mode 100644 __pycache__/classes.cpython-39.pyc create mode 100644 __pycache__/constants.cpython-39.pyc create mode 100644 classes.py create mode 100644 constants.py create mode 100644 main.py diff --git a/__pycache__/classes.cpython-39.pyc b/__pycache__/classes.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..082ff92d9f93bbd12c0bb2819f89bd03174080ba GIT binary patch literal 479 zcmY*Uy-EW?5T4yTk~0_t5#Qko^8i64lEN+o#O63y)}2*P?k>8MD-zO~m+={_eF4j} zw6eCdawZ`VXZgPQpPjM&eh*mQ-ap(Y>o0NkC1Pj9pkt;hKtQ!-yyy&2Uqc!>j{g(Q z-iSdbOdc|YkZDw?*N{aRaZlXFH{^qp**g(iI>!t;Wm>5f7+7g$g<@+2?$wiT#o07! zyA97U1-6M8wXJ-6R5#Tv2P;ox?>%uE;~?uS)i@+>B2qO zP))<^(Yrb2Sdg0qJhQbe7fT;g`k0;`P|lkI`@V-N=!FakLaKwK;VBvKfn7*ZIc7*m*{m{ORdm{VAySW;Mn z88q2m0%aLqf)u}G0ujt0f)z;kX|hJKhX%U_#e2F$aex?pj=ru@EG~{Au2Jm1uED{M z?ygasL9UL@A)fwz!7CYx*nrx=#4j6XtC-N@)S}`T$IO((yqJK>C|tkmR^ z;+T}o;^h3I6y3zU#GJ~i)S{T={Ji3l#JrMXy@JYH95%W6DWy57b|7aJa{vhzMhFA| DYBxEZ literal 0 HcmV?d00001 diff --git a/classes.py b/classes.py new file mode 100644 index 0000000..2f7bcff --- /dev/null +++ b/classes.py @@ -0,0 +1,5 @@ +class User: + def __init__ (self, user_id, username): + self.user_id = user_id + self.username = username + self.number_messages = 1 # Start with one, as user only added if spoken in channel diff --git a/constants.py b/constants.py new file mode 100644 index 0000000..2b2d1c7 --- /dev/null +++ b/constants.py @@ -0,0 +1,5 @@ +USER_ID = 0 +USERNAME = 1 +DATE = 2 +MESSAGE = 3 +REACTIONS = 5 \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..c0865b4 --- /dev/null +++ b/main.py @@ -0,0 +1,63 @@ +import csv +import constants as v +import classes as c + +# Date MM-dd-yyyy HH:mm:ss + + +# Reads from specified CSV file (specified in settings file) +# Outputs analysis to output file +def parse_file(): + temp_user = c.User('0','0') + user_array = [] + + print('Loading from CSV channel.csv') + file = open('channel2.csv', encoding="utf8") + with file as csv_file: + csv_reader = csv.reader(csv_file, delimiter=',') + line_count = 0 + + for row in csv_reader: + if line_count == 0: + line_count += 1 + else: + parse_user(row, user_array) + line_count +=1 + print(f'Done. {line_count} messages read') + print(f'Users found: {len(user_array)}') + + for user in user_array: + percentage = user.number_messages / line_count + print(f'Username: {user.username} Messages: {user.number_messages} Contribution: {percentage * 100}%') + + +# Parses current line stats and updates user_array accordingly +def parse_user(current_row, user_array): + user_id = current_row[v.USER_ID] + user_index = 0 + user_found = 0 + for user in user_array: + if user.user_id == user_id: + user_found = 1 + break + user_index += 1 + + if user_found: + # Update user stats + user_array[user_index].number_messages += 1 + else: + # If user not found, add them to array + user_array.append(c.User(user_id, current_row[v.USERNAME])) + + +# Loads settings file. +# Configures what information should be calculated and printed to output file +def load_settings(): + print('settings placeholder') + + +# Press the green button in the gutter to run the script. +if __name__ == '__main__': + parse_file() + +