Skip to main content
This guide shows how to bootstrap a small Python project from the provided GitHub repository, create and activate a virtual environment, scaffold a minimal application, split code into modules, and add a helper that calls a local Ollama model to generate fake CSV data. All examples use standard Python tooling and will work without GitHub Copilot, though Copilot can speed up scaffolding and suggestions. You can follow along with the course resources: Example repository contents typically include a license, .gitignore, GitHub Copilot instructions, and main.py. Below are concise, practical steps to go from repository to a working fake-data generator that queries a local Ollama server.

1. Clone the repository (optional)

If you received a GitHub URL, clone it and change into the project folder:

2. Create a virtual environment

Use a virtual environment to isolate dependencies per project. You can let VS Code create the environment via Python: Create Environment, or do it manually. Table: Create & activate a venv (cross-platform) When the venv is active your shell prompt typically shows the venv name, for example:
Virtual environments isolate a project’s Python packages. Always install dependencies with pip while the venv is active so they are stored inside .venv rather than globally.

3. Project scaffold: minimal main & module

Start with a minimal scaffold and keep main.py focused on orchestration. This improves testability and keeps the entrypoint simple. Example main.py:
Example fake_data_generator.py:
Run and verify:
Tip: If you began with the class inside main.py, extract it to fake_data_generator.py and import it from main.py to maintain good separation of concerns.

4. File structure (example)

Here’s a simple example file layout you can use:

5. Generate fake data via a local Ollama model

The helper script create_fake_data.py demonstrates calling a local Ollama HTTP API (default http://localhost:11434) using a model like phi4:latest and writing the returned CSV to disk. Install the runtime dependency:
Example create_fake_data.py:
Run the generator:
Note: Ollama’s response JSON schema may vary depending on model and setup. The example expects a top-level "response" containing raw CSV. If you use an Ollama client library, prefer it for richer, higher-level functionality. Sample CSV output (example fake_data.csv content):
Run the script multiple times to append or overwrite the CSV depending on how you modify the file-handling logic; this is useful if you plan to import generated data into a database.

6. Dependencies: requirements.txt

After installing packages during development, capture them for reproducibility:
To recreate the environment on another machine:
Example snippet of pip freeze output:

7. .gitignore and keeping the venv out of Git

Never commit your virtual environment to source control. Add .venv/ to .gitignore and exclude common build artifacts and IDE folders.
A dark-themed code editor/GitHub Copilot chat screenshot where a user asks how to keep git from seeing their .venv folder. Copilot is generating a response suggesting creating a .gitignore file to exclude the virtual environment.
Example .gitignore contents (abbreviated):
If you accidentally committed .venv, remove it from Git tracking and commit the change:
Do not commit your virtual environment or large generated files (like CSV data dumps) to the repository. This increases repo size and leaks machine-specific configuration.

8. Quick reference: useful commands

Summary

  • Create and activate a virtual environment (python3 -m venv .venv / source .venv/bin/activate).
  • Keep main.py minimal and split logic into modules like fake_data_generator.py.
  • Use create_fake_data.py to call a local Ollama model and write raw CSV output to a file.
  • Record dependencies with pip freeze > requirements.txt.
  • Use .gitignore to exclude virtualenvs and other local artifacts from Git.
  • GitHub Copilot can speed up scaffolding, but the patterns shown here are standard Python best practices and will work without Copilot.
Next steps you might explore:
  • Load the generated CSV into a database and expose a small API to query the fake data.
  • Enhance the generator to accept command-line arguments (rows, model, output file).
  • Integrate a proper Ollama client library for streaming or richer model control.

Watch Video