Skip to content

Commit

Permalink
outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
wolff01 committed May 4, 2024
1 parent 21ed970 commit 8a0da6f
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import pandas as pd

def sum_csv(filename, start_row, end_row, start_col, end_col):
"""Addition portion of code"""
with open(filename, 'r') as file:
csv_reader = csv.reader(file)
data = list(csv_reader)

# Reads start and ending of rows
start_row = max(0, min(start_row, len(data)-1))
end_row = max(start_row, min(end_row, len(data)-1))

# Reads start and ending of cloumns
start_col = max(0, min(start_col, len(data[0])-1))
end_col = max(start_col, min(end_col, len(data[0])-1))

Expand All @@ -20,13 +21,14 @@ def sum_csv(filename, start_row, end_row, start_col, end_col):
return sums

def multiply_csv(filename, start_row, end_row, start_col, end_col):
"""Multiplication portion of code"""
with open(filename, 'r') as file:
csv_reader = csv.reader(file)
data = list(csv_reader)

# Reads start and ending of rows
start_row = max(0, min(start_row, len(data)-1))
end_row = max(start_row, min(end_row, len(data)-1))

# Reads start and ending of columns
start_col = max(0, min(start_col, len(data[0])-1))
end_col = max(start_col, min(end_col, len(data[0])-1))

Expand All @@ -37,6 +39,7 @@ def multiply_csv(filename, start_row, end_row, start_col, end_col):
return products

def divide_csv(filename, start_row, end_row, start_col, end_col):
"""Division portion of code"""
sums = sum_csv(filename, start_row, end_row, start_col, end_col)
products_1 = multiply_csv(filename, start_row, end_row, 3, 4)
products_2 = multiply_csv(filename, start_row, end_row, 3, 5)
Expand All @@ -48,15 +51,15 @@ def divide_csv(filename, start_row, end_row, start_col, end_col):
division_results_2.append(prod_val / sum_val)
else:
division_results_2.append(float('NaN'))

# Adds necessary data to second list
for sum_val, prod_val in zip(sums, products_2):
if sum_val != 0:
division_results_1.append(prod_val / sum_val)
else:
division_results_1.append(float('NaN'))

# Adds necessary data to first list
column_names = [((res_1 * res_2)* 100)for res_1, res_2 in zip(division_results_1, division_results_2)]

# Merges both lists

st.title("Perfect Timing")

Expand All @@ -70,7 +73,9 @@ def divide_csv(filename, start_row, end_row, start_col, end_col):
st.table(df_sorted)

def csv_row_range(filename, start_row_index, end_row_index):
"""Range portion of code"""
with open(filename, 'r') as file:
# Reads the csv file
csv_reader = csv.reader(file)
rows = list(csv_reader)
result = []
Expand Down

0 comments on commit 8a0da6f

Please sign in to comment.