Software Engineer (SDE)pythonbeginner3 interactive MCQs in app
JSON & CSV Parsing
csv.DictReader vs naive split(",")json.loads vs json.load streamsnewline="" Windows CSV pitfall
Core Concept
`json.loads` / `json.dumps` parse/serialize JSON strings cleanly (`load`/`dump` work on file streams), rejecting comments, trailing commas, and single quotes cleanly with `json.JSONDecodeError`. For CSVs containing quoted commas (`"Doe, Jane", 95`) or newlines inside cells, ALWAYS use `csv.DictReader` / `csv.writer` paired with `newline=""`—NEVER split rows naively with `line.split(",")`!
Worked Example
on row `101,"Doe, Jane",95`, `csv.DictReader` yields `name = "Doe, Jane"`, whereas `row.split(",")` wrongly cuts `"Doe` from `Jane"`!
Common Pitfall
`line.split(",")` shatters `"San Francisco, CA"` into two columns, and omitting `newline=""` adds blank lines on Windows CSV writes.
Recommended Readings & Practice
Practice JSON & CSV Parsing with 3 graded MCQs & written feedback.
Take SOARDO’s free 12-question diagnostic to see how strong you are across your target role and unlock adaptive daily missions.