Networking Data & Formats
Why Structured Data Matters for Automation
What you'll learn
- The difference between unstructured text and structured data
- Why a Python dict or list living in memory isn't enough on its own
- The round trip: Python data → a file on disk → Python data again
- A first look at what JSON, YAML, and CSV are each best suited for
- That the right format depends on the job — not one format for everything
Listen to a guided explanation of this lesson.
Spoken narration isn't supported in this browser.
Text a script can trust
Raw show command output is text meant for a person to read: column widths that shift, headers that vary slightly between platforms, blank lines in inconsistent places. A script can pick data out of it, but every quirk of that output is something the script has to work around.
Structured data is the opposite: text with an explicit, predictable shape — clear boundaries between fields, a consistent way to represent a list versus a single value versus nothing at all. {"hostname": "SW1", "ip": "10.10.10.1"} isn't just readable, it's parseable — a script can turn it directly into a dictionary without guessing where one field ends and the next begins.
You've already been working with structured data all module — every device dictionary and every list of devices from "Python for Network Engineers" was structured data, living in Python's memory while the script ran. This lesson is about what happens to that same data once the script needs to save it, share it, or hand it to something that isn't Python at all.
A useful way to think about it
Structured data isn't a new idea — it's the same shape you've already been using as Python dicts and lists. This module is about the different ways to write that shape down as text, so it can live somewhere other than inside a running script.
The round trip
A Python dictionary only exists while the script that created it is running — the moment the script ends, it's gone. If you want an inventory to still be there tomorrow, or want a teammate who's never opened Python to read your report, that data has to leave memory and become a file on disk.
- Python dict / listin memory, while the script runs
- Write to a filethe data becomes text — JSON, YAML, or CSV
- File on diskcan be saved, emailed, version-controlled, read by other tools
- Read from the filetext is turned back into structured data
- Python dict / listback in memory, ready to use again
This round trip — memory to file and back — is exactly what the rest of this module teaches: how to write Python data out as JSON, YAML, or CSV, and how to read each of them back in.
Three formats, three different strengths
You'll go deep on each of these in the next three lessons — for now, just the shape of the map:
- JSON — nests naturally (dictionaries inside dictionaries, lists of dictionaries), and is what most device APIs and modern CLI
| jsonoutput already speak. Best when data has real structure and needs to move between programs. - YAML — represents the same kind of structured data as JSON, but written to be easy for a person to read and hand-edit. This is why Ansible playbooks, Nornir inventories, and countless config files are YAML rather than JSON.
- CSV — the simplest of the three: a flat table, one row per item, the same columns every time. Excellent for a straightforward device inventory list; awkward the moment the data isn't flat.
Key takeaways
- Structured data has a predictable, explicit shape that a script can reliably parse — unlike raw, free-form command output.
- A Python dict or list only exists in memory while its script runs; writing it to a file is what lets it persist and be shared.
- The core pattern this module teaches: Python data → written to a file → read back into Python data, for JSON, YAML, and CSV.
- JSON nests naturally and is common in device APIs; YAML is written for humans to hand-edit; CSV is a simple flat table.
- The right format depends on the shape of the data and who (or what) needs to read it — not one universal choice.