See attachedfrom openpyxl import load_workbook # Open the SalesData spreadsheet workbook = load_workbook(“SalesData.xlsx”) sheet =

See attached

from openpyxl import load_workbook

# Open the SalesData spreadsheet
workbook = load_workbook(“SalesData.xlsx”)
sheet = workbook.active

# Grab columns A (Date), C (Rep), and G (Total Sales), except title row
gridData = sheet.iter_rows(min_row=2, min_col=1, max_col=7, values_only=True)

# Convert that data into a list, filtering out non-numeric sales values
salesList = []
salesDetails = [] # List to store details (date, rep, and total sale)

for nextRow in gridData:
date = nextRow[0] # Date is in column A (index 0)
rep = nextRow[2] # Salesperson is in column C (index 2)
total_sale = nextRow[6] # Total sale is in column G (index 6)

# Check if the total sale is numeric (to avoid errors from text or blank cells)
if isinstance(total_sale, (int, float)):
salesList.append(total_sale)
salesDetails.append((date, rep, total_sale)) # Store corresponding details

# Find the index of the largest sale
if salesList:
max_sale = max(salesList)
max_index = salesList.index(max_sale)

# Get the corresponding date and salesperson from the salesDetails list
max_sale_date, max_sale_rep, max_sale_value = salesDetails[max_index]

# Print the result
print(f”Largest Sale was {max_sale_value} made on {max_sale_date} by {max_sale_rep}”)
else:
print(“No valid sales data found.”)

Share This Post

Email
WhatsApp
Facebook
Twitter
LinkedIn
Pinterest
Reddit

Order a Similar Paper and get 15% Discount on your First Order

Related Questions

Follow the attach instructions to complete this work.Analyzing a Business Function – Project Management   Must post first. Subscribe Nofsinger

Follow the attach instructions to complete this work. Analyzing a Business Function – Project Management   Must post first. Subscribe Nofsinger Consulting Services uses Project Management techniques to manage client engagements. One of the primary responsibilities of the engagement project managers is ensuring that the advisory services and associated written