See attached from 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 document to complete this work. International Cooperation for Cybersecurity   Prepare a 5- to 7-paragraph briefing statement

Follow the attach document to complete this work. International Cooperation for Cybersecurity   Prepare a 5- to 7-paragraph briefing statement that explains why wealthy nations and developing nations should work together to improve cybersecurity for the globally connected networks referred to as “the Internet.” Your statement should address the following.

Project 4: Postmigration Activities  Step 1: Postmigration Activities Overview  Like any software development project, migration projects require

Project 4: Postmigration Activities  Step 1: Postmigration Activities Overview  Like any software development project, migration projects require careful planning to ensure success. This planning includes the postmigration testing and maintenance phase. Start this project by researching and planning the  postmigration activities that will be required to get BallotOnline’s migrated workloads in