4 - Modules, File I/O, and Error Handling — Reading and Writing CSV Files, Working with JSON

Python Docs – csv Module

Full Title: csv — CSV File Reading and Writing

The official reference for Python's csv module, covering csv.reader, csv.writer, csv.DictReader, and csv.DictWriter with full parameter descriptions and examples. It is the authoritative source for understanding every option and dialect available when reading and writing CSV files.

Python Docs – json Module

Full Title: json — JSON Encoder and Decoder

The official documentation for Python's built-in json module, detailing json.loads, json.load, json.dumps, and json.dump, along with supported types and known limitations. It is essential for understanding serialization options, encoding parameters, and the boundaries of what the standard library's JSON support can handle.

Automate the Boring Stuff – CSV and JSON

Full Title: Automate the Boring Stuff with Python, 2nd Edition

Chapter 16 of this freely available, beginner-friendly book walks through practical, real-world examples of reading and writing CSV files with Python's csv module and working with JSON data using the json module. Its approachable style makes it an ideal companion resource for learners new to structured data file handling.

Real Python – Reading and Writing CSV Files

Full Title: Reading and Writing CSV Files in Python

This in-depth tutorial covers CSV file concepts and demonstrates the use of csv.reader, csv.writer, csv.DictReader, and csv.DictWriter with annotated code examples and explanations of common pitfalls. It complements the official documentation by providing narrative context and side-by-side comparisons of the different reading and writing approaches.

Real Python – Working with JSON

Full Title: Working With JSON Data in Python

A thorough tutorial explaining JSON fundamentals, Python type mappings, and practical use of json.loads, json.load, json.dumps, and json.dump, including use cases such as configuration files. It also addresses limitations of the standard json module, making it directly aligned with all subtopics in the JSON section of this course material.

ECMA-404 JSON Standard

Full Title: ECMA-404: The JSON Data Interchange Standard, 2nd Edition

The formal specification defining the JSON data interchange format, including its syntax rules for objects, arrays, strings, numbers, and literal values. Understanding the standard helps learners grasp why Python's json module has certain limitations and how JSON structure maps to Python data types.

RFC 4180 – CSV Format

Full Title: RFC 4180: Common Format and MIME Type for Comma-Separated Values (CSV) Files

The de facto specification for the CSV file format, describing field delimiters, quoting rules, line endings, and MIME type registration. Consulting this document gives learners a precise understanding of what a well-formed CSV file looks like and why Python's csv module is designed the way it is.

Python Cookbook – Data Structures and Algorithms

Full Title: Python Cookbook, 3rd Edition

Chapters 6 of this highly regarded cookbook provides recipe-style solutions for reading and writing CSV and JSON data in Python, including handling edge cases, nested structures, and custom serialization. Its concise, problem-solution format makes it a valuable reference for learners who want to move beyond basic usage to more robust, production-ready patterns.