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

 The Rest of the resources and instructions are provided in the screenshots below. You will need the Project overview to complete this

 The Rest of the resources and instructions are provided in the screenshots below. You will need the Project overview to complete this assignment. Project Overview This project includes the following tasks: Gather product information Analyze and differentiate product vulnerabilities Recommendation based on empirical data collection Objective: Product Selection Recommendation Organizations

 How Does Surescripts Integration Improve Prescription Management?  The Future of E-Prescriptions: Why Surescripts Integration is a Must-Have In

 How Does Surescripts Integration Improve Prescription Management?  The Future of E-Prescriptions: Why Surescripts Integration is a Must-Have In today’s fast-evolving healthcare landscape, seamless data exchange is essential for improving patient care and optimizing workflows. Surescripts integration solutions provide a secure and efficient way to connect pharmacies, healthcare providers, and electronic

[url= Integration Services[/url] are transforming businesses by streamlining operations, enhancing customer experiences, and enabling data-driven

[url= Integration Services[/url] are transforming businesses by streamlining operations, enhancing customer experiences, and enabling data-driven decisions. By automating repetitive tasks, AI frees up resources for more strategic activities, improving productivity. AI tools like chatbots and recommendation engines offer personalized solutions, fostering customer loyalty. AI also helps businesses analyze large datasets