Create a CSV Dataset Explorer
Level: Beginner · Time: 25–35 min · Category: Data app
Tags: Python · Streamlit · Prompting
Use AI coding assistance to build a small Streamlit app for previewing, filtering, and summarizing CSV files.
This is a good first AI-assisted project because every change is visible in the browser and the app can stay local.
Prerequisites
- Getting Started with AI — the full setup guide: API key, coding assistant, and the prompting habits these tutorials assume. Start here if you have not already.
- LLM API Guide — set up API access so an assistant can help explain and extend the app.
- Use Python with the LLM gateway — review basic Python environment and SDK setup.
- Python — install Python if your workstation does not already have it.
- Sample CSV — download a small lab-results CSV for testing the tutorial app.
Confirm Python 3 and pip are available before you start:
New to this? What are Python and pip?
Python is the programming language these tutorials use. You run a Python program by typing python (or python3) followed by the file name.
pip is Python's package installer. It downloads add-on libraries your program needs (like the OpenAI SDK) from the internet. It comes with modern Python installs, so you do not install it separately.
Install Python 3.9 or newer. Pick your operating system:
- macOS / Linux
- Windows
macOS with administrative permissions: if you have administrative permissions, download the latest installer from python.org/downloads, open the .pkg, and click through it. If you use Homebrew, you can instead run brew install python.
Linux with administrative permissions: most distributions already include Python 3. If not, install it with your package manager, for example sudo apt install python3 python3-pip (Debian/Ubuntu).
macOS / Linux without administrative permissions: if you lack administrative permissions, such as due to using an ASU-issued computer, instead install Miniforge. This will include Python.
Do not install your own Python. Load a provided module instead — for example module load python — then run the checks below.
Download the installer from python.org/downloads and run it. On the first screen, check the box "Add python.exe to PATH" before clicking Install — this is the step people most often miss, and skipping it means your terminal cannot find python afterward.
After it finishes, close and reopen your terminal (PowerShell).
Now confirm Python and pip work. Each should print a version number:
- macOS / Linux
- Windows (PowerShell)
python3 --version # expect 3.9 or newer
python3 -m pip --version
python --version # expect 3.9 or newer
python -m pip --version
This almost always means your terminal was open before you installed Python, or the "Add to PATH" box was left unchecked on Windows. Fully quit and reopen the terminal and try again; if it still fails, reinstall using the steps above.
What you will do
- Install Streamlit and pandas.
- Prompt for a first local data explorer.
- Ask for careful improvements like filters and downloads.
- Troubleshoot common CSV and dependency problems.
Build it step by step
1. Install dependencies
Create a small Python environment for the app. This keeps Streamlit dependencies separate from other projects.
- macOS / Linux
- Windows (PowerShell)
mkdir dataset-explorer
cd dataset-explorer
python3 -m venv .venv
source .venv/bin/activate
pip install streamlit pandas
mkdir dataset-explorer
cd dataset-explorer
python -m venv .venv
.venv\Scripts\Activate.ps1
pip install streamlit pandas
If you track this project with Git, do not commit your virtual environment or any secrets. Create a .gitignore file in the project folder with at least these lines:
.venv/
.env
__pycache__/
.venv/ is large and specific to your machine, and .env holds your API key — neither belongs in a shared repository. New to Git? See Track a New Project with Git.
2. Add API connection values
If you are completing this tutorial after another where you set up the .env file, you may copy that file here instead of generating a new one. If so, skip to the next step.
Otherwise, set it up now.
Your program needs three values to reach the API: your API key, the gateway URL, and a model ID. You keep them in a small text file named .env so they stay out of your code — and out of Git.
What is a .env file, and where does it go?
A .env ("dot-env") file is a plain text file that stores settings as NAME=value lines, one per line. Programs read it at startup so you never have to paste secrets like API keys directly into your code.
- The filename is literally
.env— a leading dot with nothing before it (notconfig.envor.env.txt). - It goes in your project folder: the same directory you just created, where the
.venvlives and where you run your commands. - The
python-dotenvpackage loads it withload_dotenv(), which looks for.envin the folder you run the program from. - Because it holds a secret, never commit it to Git (see the note below).
Create a new file named .env in your project folder — in VS Code use File → New File, or run code .env in the terminal — then paste these three lines and replace the placeholders:
OPENAI_API_KEY="paste-your-key-here"
OPENAI_BASE_URL="https://openai.rc.asu.edu/v1"
RC_LLM_MODEL="paste-model-id-here"
Get your API key and a valid model ID from the LLM API guide. The OPENAI_BASE_URL above is already correct for the Research Computing gateway.
- Use the
/v1base URL, not the full/chat/completionsURL, for the Python SDK. - Use a model ID that appears in the voyager model list for your account.
- Keep
.envout of Git: add a line containing.envto your.gitignore(see Track a New Project with Git).
3. Use OpenCode to generate a first version
First, open OpenCode in your project directory:
- Desktop app
- Terminal
Open the OpenCode desktop app and point it at this project folder (dataset-explorer).
Start OpenCode in terminal by calling it directly:
opencode
Now, give the assistant the app goal, the dependencies it may use, and the safety constraints around uploaded files.
You are helping me build a beginner Streamlit app.
Project goal:
- Let a user upload a CSV.
- Show the first rows.
- Show row count, column count, and missing value count.
- Let the user choose one column and show a simple summary.
Constraints:
- Use Streamlit and pandas.
- Keep the first version in app.py.
- Add friendly errors for malformed CSV files.
- Do not add a database or login.
- I will test with a sample file named lab-results-example.csv.
Please:
1. Create app.py.
2. Explain how to run it locally.
3. Suggest two small next improvements.
4. Run and test with the sample CSV
Start Streamlit and test with the sample lab-results file before trying a large research dataset.
On Windows, use curl.exe instead of curl.
curl -L -o lab-results-example.csv https://docs.rc.asu.edu/tutorials/lab-results-example.csv
streamlit run app.py
Or create the sample CSV manually:
cat > lab-results-example.csv <<'CSV'
sample_id,condition,replicate,day,value,unit,passed_qc,notes
S001,control,1,0,12.4,ng/uL,true,Baseline sample
S002,control,2,0,11.8,ng/uL,true,Baseline sample
S003,control,3,0,13.1,ng/uL,true,Baseline sample
S004,treatment-a,1,1,18.6,ng/uL,true,Clear response
S005,treatment-a,2,1,17.9,ng/uL,true,Clear response
S006,treatment-a,3,1,,ng/uL,false,Instrument timeout
S007,treatment-b,1,1,15.2,ng/uL,true,Moderate response
S008,treatment-b,2,1,14.7,ng/uL,true,Moderate response
S009,treatment-b,3,1,15.9,ng/uL,true,Moderate response
S010,control,1,7,12.9,ng/uL,true,Follow-up
S011,treatment-a,1,7,21.4,ng/uL,true,Follow-up
S012,treatment-b,1,7,16.8,ng/uL,true,Follow-up
CSV
streamlit run app.py
5. Ask for one practical improvement
The best follow-up prompts name one feature and ask how to test it with a small file.
Please improve the dataset explorer with one focused feature:
Feature:
- Add a download button for the filtered dataframe.
Constraints:
- Keep the app beginner-readable.
- Do not rewrite the whole file if a smaller change works.
- Explain how to test the new button with lab-results-example.csv.
More prompts to try
- Add a date range filter, but only show it when a date-like column exists.
- Review this app for friendly errors when the uploaded CSV is malformed.
- Suggest three improvements for
lab-results-example.csvthat would help a collaborator who does not write Python, then wait for me to choose one.
Troubleshooting
- If
streamlitis not found, activate the virtual environment again and runpip install streamlit pandas. - If curl cannot download the sample file, use the manual CSV block above instead.
- If pandas cannot read the file, ask the assistant to add try/catch handling around
pd.read_csv. - If the app is slow with a large CSV, ask for row limits, cached loading, or column selection before display.
- If the assistant adds too many charts at once, ask it to revert and add one chart tied to one selected column.
Next steps
- Create a lab portal — turn a useful prototype into a more polished web portal.
- Set up OpenCode — use a coding assistant to make focused improvements.