- Lab
-
Libraries: If you want this lab, consider one of these libraries.
JSON Inventory Reports in Python
Build a Python command-line restock reporter that reads nested inventory data from JSON, finds low-stock products, and produces both a console summary and a saved report. The lab focuses on drilling into dictionaries that contain lists of dictionaries, extracting nested values, and combining small helper functions into a complete workflow. By the end, you will be comfortable loading JSON, flattening nested data, filtering records, and formatting the results for users.
Lab Info
Table of Contents
-
Challenge
Explore the project and reporting goal
Welcome to this lab! You are going to complete a small Python reporting utility that reads nested inventory data and turns it into useful reorder information for a store manager. info> This lab experience was developed by the Pluralsight team using an internally developed AI tool. All sections were verified by human experts for accuracy prior to publications. However, content may still contain errors or inaccuracies, and we recommend independent verification.
To report a problem or provide feedback, click here. Feedback may be used to improve accuracy in accordance with our Privacy Policy. -
Challenge
Load and traverse nested inventory data
This step establishes the data-processing foundation for the rest of the lab. Before you can summarize or report anything, you need to read the inventory file into memory and understand how to move through its nested structure.
-
Challenge
Extract nested fields and build summaries
This step moves from simple traversal into focused data extraction and summarization. Once you can identify the low-stock products, the next question is what information a manager actually needs in order to act.
-
Challenge
Assemble and export the report payload
This step is where the application begins to feel complete. Up to now, each helper has produced one focused output: a filtered list, a list of emails, a totals dictionary, or a list of display lines.
-
Challenge
Present the results and wire the application flow
The final step turns a collection of helpers into an actual command-line application. A useful script does more than compute a result silently; it usually presents a summary to the user and coordinates its own workflow from input to output. You've built all the pieces of the reporting workflow. Now it's time to run the application and see everything working together.
Run the application from the Terminal tab:
python3 -m restock_reporter.appVerify the console output:
- Includes the warehouse name.
- Includes the low-stock product count.
- Includes a comma-separated list of supplier email addresses.
- Includes an
Items:section with a bullet for each low-stock product.
Example output:
Warehouse: Central Depot Low-stock products: 4 Supplier emails: [email protected], [email protected], [email protected] Items: - APL-01 | Apples | qty 12 | reorder at 15 ...Verify the report file:
- The application creates:
output/restock_report.json - The JSON file contains the following keys:
warehouselow_stock_countsupplier_emailsitemssection_totals
Perform a final sanity check:
- The warehouse name in the console matches the warehouse name in the JSON file.
- The value of
low_stock_countmatches the number of entries initems. - The supplier email list contains no duplicates.
- The section totals look reasonable based on the inventory data.
If all of these checks pass, you've successfully completed the restock reporting workflow from end-to-end.
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.