Simple Python tools to download the CDC NSSP Emergency Department Visit Trajectories dataset and produce a cleaned Texas extract suitable for Tableau or further analysis.
- Fetches the NSSP trajectories CSV from CDC (raw export).
- Provides a filtering script that narrows the dataset to Texas (and optionally 2024).
- Includes a small debugger/analysis script for quick testing.
nssp_fetch_state_tx.py— fetch raw NSSP CSV (CDC / Socrata), save tooutputs/.filter_nssp_tx.py— filter the raw CSV to Texas rows and writeoutputs/nssp_tx_all_years.csvandoutputs/nssp_tx_2024.csv.nssp_fetch_and_analysis.py— lightweight debugger / analysis runner (used for testing; prints status, runs mini-EDA).outputs/— (generated) directory where CSVs and figures are written.README.md— this file.
(If you have other helper scripts in the folder, they’re optional — the three above are the main flow.)
- Python 3.8+ (recommended)
- pip
Packages required:
pandasrequestsnumpyscikit-learnscipymatplotlib
Install quickly:
python -m pip install --upgrade pip
python -m pip install pandas requests scikit-learn numpy scipy matplotlibOr create requirements.txt and install:
pandas
requests
numpy
scikit-learn
scipy
matplotlib
python -m pip install -r requirements.txt- Fetch the CDC NSSP export (raw CSV) — writes into
outputs/:
python nssp_fetch_state_tx.py- Filter raw CDC export to Texas (and 2024 if available):
python filter_nssp_tx.py- Run the debugger / quick analysis (optional):
python nssp_fetch_and_analysis.pyAfter running the two main scripts you should have outputs/nssp_tx_all_years.csv (and outputs/nssp_tx_2024.csv if 2024 rows exist). Those files are ready for Tableau or downstream analysis.
A live map/dashboard built from a cleaned export is available here:
Use the nssp_tx_all_years.csv / nssp_tx_2024.csv as the data source in Tableau. Prefer 5-digit FIPS for reliable county mapping.
outputs/nssp_cdc_raw.csv— raw CDC/Socrata download (saved by fetch script)outputs/nssp_tx_all_years.csv— Texas rows (all years)outputs/nssp_tx_2024.csv— Texas rows filtered to 2024 (if present)outputs/*.pngoroutputs/figs/— any plots generated by the debugger/analysis scripts
ModuleNotFoundError: No module named 'matplotlib'— run thepip installcommand above.- No rows returned from API for county/state? NSSP sometimes suppresses county-level rows — use the CDC CSV export (Socrata) fetch (the fetch script does this).
- If mapping in Tableau fails, prefer
FIPS5(5-digit FIPS). County name mismatches are common.
- Data source: CDC NSSP Emergency Department Visit Trajectories (Socrata dataset
rdmq-nq56). Cite CDC if you publish results. - These scripts are intended for exploratory / capstone work (Coursera capstone). Not production-grade ETL.
MIT-style (do what you want, please cite the dataset). Questions or want a quick Tableau-ready CSV or sample map exported as PNG? Open an issue or ping me.