127| PYTHON – P&L Prep

BYU Student Author: @Keanu_Gauthier , @Spencer
Reviewers: @Abraham_Reyes_Leon, @Jason_Nguyen
Estimated Time to Solve: 20 Minutes

We provide the solution to this challenge using:

Need a program? Click here.

Overview
As a new hire at a small accounting firm, your task is to prepare the Profit & Loss (P&L) statement for one of your clients, the “Cookie Company”. The P&L data has been correctly accounted for and placed in the statement. However, some accounts have zero balances and need to be removed.

Your task is to automate this process using a Python script so that next month, the task can be completed by simply running the script.

Instructions

  1. Read the P&L sheet from the provided Excel file.
  2. Create a new sheet named “Final P&L”, which is a copy of the original “P&L” sheet. This ensures that the original data remains untouched.
  3. Iterate through each account in the “Final P&L” sheet. If an account has a balance of 0, delete the entire row.
  4. Ensure that Column F is hidden in the “Final P&L” sheet.
  5. Count how many rows were removed.Display a message: “The Final P&L is ready for review. X accounts have been removed.” (where X is the number of deleted accounts)
  6. Save the modified Excel file as a new file (P&L_Cleaned.xlsx). Ensure that all changes are properly applied.

Data Files

Suggestions and Hints

Make sure to use openAI if you get stuck along the way. Copy paste the errors you may have to debug them. Have fun!

Solution