Skip to main content
MahiDev — Learn. Build. Become AI-ready.

Module 16

Files, Pickling, CSV, JSON, and OS Operations

Learn file handling and common data exchange formats.

Intermediate5 hours12 lessons

01

Files and Streams — Data Persistency in Python

Learn why Python files exist: data persistency, the stream between memory and disk, and how text files differ from binary files.

Intermediate25 min

02

File Opening Modes — r, w, a, r+, w+, a+, x, and x+

Learn each of the eight Python file modes — r, w, a, r+, w+, a+, x, and x+ — including overwrite, append, and exclusive create.

Intermediate25 min

03

Opening Files — open() and with open() as

Open a Python file with open() or with open(), and close it manually or automatically so the saved record stays consistent.

Intermediate25 min

04

Writing Files — write() and writelines()

Write text into a Python file with write() and writelines(), and convert numbers to strings before they are stored as characters.

Intermediate25 min

05

Reading Files — read() and readlines()

Read a Python text file with read() into one string, or with readlines() into a list of lines, and handle a missing file.

Intermediate25 min

06

Random Access — tell() and seek() on a File Pointer

Move inside a Python file with tell() and seek(), read a slice with read(n), and jump the pointer back to any character index.

Intermediate25 min

07

Binary Files — Read and Write Bytes with Mode b

Open Python files in binary mode with b, copy bytes with read and write, and keep images and other media out of text mode.

Intermediate25 min

08

Pickling and Unpickling — pickle.dump() and pickle.load()

Pickle one whole Python object into a binary file with dump(), then restore that same object in a single read with load().

Intermediate25 min

09

CSV Files — csv.writer and csv.reader

Store tabular data rows in a Python CSV file using csv.writer, then read each comma-separated record back using csv.reader.

Intermediate25 min

10

CSV Dicts — DictWriter and DictReader

Write dictionary rows to a CSV file with DictWriter and writeheader(), then read each row back as a dict with DictReader.

Intermediate25 min

11

JSON Files — loads, dumps, load, and dump

Convert between Python dicts and JSON text with loads and dumps, and move dicts to and from .json files with load and dump.

Intermediate25 min

12

OS Operations — Folders and Files with the os Module

Create, list, rename, and remove files and folders in Python with mkdir, makedirs, listdir, rename, remove, rmdir, and removedirs.

Intermediate25 min