Skip to content
Learn Netverks

Lesson

Step 25/36 69% through track

json-csv-python

JSON and CSV

Last reviewed May 28, 2026 Content v20260528
Track mode
server_script
Means
Server runner
Reading
~1 min
Level
intermediate

This lesson

This lesson teaches JSON and CSV: the syntax, patterns, and safety habits you need before advancing in Python.

Teams still ship JSON and CSV in Python codebases—skipping it leaves gaps in debugging and code reviews.

You will apply JSON and CSV in contexts like: API glue, data imports, and reporting scripts.

Write Python 3 in the editor and click Run on server—the dev runner executes your script with print() for output; stdlib only in playground snippets (LEARNING_RUNNER_ENABLED=true).

When you can explain the previous lesson's ideas without copying starter code.

The stdlib json and csv modules parse common interchange formats—no pip install. JSON maps to Python dicts/lists; CSV suits tabular exports from spreadsheets and logs.

JSON

import json

data = {"name": "Ada", "scores": [10, 20]}
text = json.dumps(data, indent=2)
parsed = json.loads(text)

CSV

import csv, io

output = io.StringIO()
writer = csv.writer(output)
writer.writerow(["name", "score"])
writer.writerow(["Ada", 99])
print(output.getvalue())

Important interview questions and answers

  1. Q: JSON types in Python?
    A: object→dict, array→list, string→str, number→int/float, true/false→bool, null→None.
  2. Q: csv module vs pandas?
    A: csv is stdlib for simple files; pandas (PyPI) adds DataFrame analytics—install locally for data science.

Self-check

  1. What function parses a JSON string?
  2. What module writes CSV rows?

Tip: json.loads returns Python types—validate untrusted JSON before use in apps.

Interview prep

JSON to Python types?

object→dict, array→list, string→str, number→int/float, true/false→bool, null→None.

csv vs pandas?

csv stdlib for simple files; pandas DataFrame analytics require local pip install.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • json.loads?
  • csv DictReader?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump