Skip to main content
In this lesson you’ll scaffold a small Python project, move implementation into modules following Python best practices, use a local LLM (see Running Local LLMs With Ollama) to generate fake CSV data, and manage dependencies and .gitignore entries. Prerequisites:
  • Python 3.8+ installed (the IDE example uses Python 3.13).
  • Optional: Ollama running locally if you want to call the Ollama example (see course: Running Local LLMs With Ollama).

1) Create the project and virtual environment

Create a project directory, open it in your editor, and keep the virtual environment local to the project:
Create and activate a virtual environment. macOS / Linux:
Windows (PowerShell):
Install packages inside the activated environment:
When the venv is active your shell prompt typically shows the environment name:
Keep your virtual environment directory local to the project (for example, .venv/). Add it to .gitignore so it is not committed to version control.

2) Scaffold a minimal application

Start with a tiny main.py that creates and runs a FakeDataGenerator instance. This keeps your entry point simple while implementation details live in separate modules.
Run it:
Expected output:

3) Move the generator to its own module

Create fake_data_generator.py and keep the class implementation there. This improves testability and makes the project more maintainable.
Now main.py imports this module and calling python main.py should print the same message.

4) Generate fake CSV data using a local LLM (Ollama)

We provide a small script create_fake_data.py that builds a prompt, calls Ollama’s HTTP API, and writes the returned CSV to a file. Adjust the model and URL if your Ollama deployment differs. Install requests in the venv:
Create create_fake_data.py:
Run the script (with Ollama running and the requested model available):
A successful run might produce fake_data.csv with contents like:
Ollama responses and API shapes can change between releases. If the script returns unexpected JSON, inspect the raw response to find the correct key (for example response, output, or text) and update the parsing accordingly.
Note: Running Local LLMs With Ollama provides an official Python client that can offer streaming and structured APIs. The HTTP POST shown here is a simple, broadly compatible pattern.

5) Save dependencies (requirements.txt)

Capture the project dependencies so others can recreate the environment:
Example requirements.txt (versions will vary):
Install on another machine:

6) .gitignore and keeping the venv out of Git

Create a .gitignore at the repository root to exclude the virtual environment and common artifacts.
If you accidentally committed the venv already, remove it from tracking:
Dark-themed screenshot of a developer chat where a user asks how to keep Git from seeing their .venv folder. GitHub Copilot is shown responding and suggesting to create a .gitignore to exclude the virtual environment.

Project files overview


Summary

  • Created a project, and isolated dependencies in a local Python virtual environment.
  • Scaffolding: small main.py plus fake_data_generator.py for implementation.
  • Built create_fake_data.py to call a local Ollama model and save CSV output.
  • Saved dependencies with pip freeze > requirements.txt.
  • Added a .gitignore to keep the virtual environment and editor artifacts out of version control.
Links and references: A future lesson will cover persisting generated fake data into a database and querying it for reuse.

Watch Video