Skip to main content
Writing all your Python in a single file is fine for small experiments, but real projects grow quickly and need a structure that keeps things findable. Separating your source code, raw data files, and generated outputs into dedicated folders means you always know where to look — and so does anyone else who picks up your project. In this page, you’ll set up a simple but professional layout for a sales analysis project inside your existing workspace.

Organize your workspace

You already have a python-for-ai workspace from earlier in the course. Open it in VS Code and add a dedicated project folder with this layout:
Create folders in VS Code by right-clicking in the Explorer panel and selecting New Folder, or by clicking the new-folder icon at the top of the Explorer pane.

Create the data file

Inside sales-analysis/data/, create a file called sales.csv with the following content:
Copy and paste this data directly into a new file. Make sure the file extension is .csv, not .txt — VS Code may try to add .txt if you’re not careful.

Understanding file paths in your project

When your script runs, Python looks for files relative to the folder it’s running from. If you keep your script in the sales-analysis/ folder, these paths will work:

Create your first script

In the sales-analysis/ folder (not inside a subfolder), create analyzer.py:

Running your code

VS Code gives you two convenient ways to run Python code:

Option 1: The Play button

  1. Open analyzer.py in VS Code
  2. Click the ▶️ button in the top-right corner
  3. Output appears in the terminal below
  1. Open analyzer.py in VS Code
  2. Place your cursor on any line (or select a block)
  3. Press Shift + Enter
  4. The code runs in an interactive window and you see results immediately
Interactive mode lets you run code line by line and inspect variables as you go. It’s excellent for understanding what each step does and debugging as you write.
Keeping analyzer.py at the top of your project folder — alongside data/ and output/ — means file paths stay simple and consistent whether you use the Play button or interactive mode.

Best practices

  1. Keep data separate — Never mix your Python scripts and your data files in the same folder
  2. Use clear namesdata/ for inputs, output/ for results makes the project self-documenting
  3. Put scripts at the project root — Your main script should sit at the same level as data/ and output/
  4. Test incrementally — Use Shift + Enter to run and verify each section as you write it

Python paths

Learn how Python finds your files and imports