Reading files and CSVs

Real data arrives as a slightly wrong file. Encodings, delimiters, and missing values are the first three problems you will meet.

Lesson 1.36m 35sBeginner28.2k students

Chapters

6:35
  1. 0:00Intro
  2. 0:18What is a CSV file?
  3. 1:06Read in Python using csv.reader
  4. 2:24Skipping the CSV header
  5. 3:33Read in Python using DictReader
  6. 4:14Change Separator or Delimiter
  7. 5:12Read CSV in Python by column using Pandas

What this lesson covers

  • Read and write files safely with context managers
  • Parse CSV data and handle encoding issues
  • Deal with missing and malformed rows on load

This lesson sits in Python Foundations for Data, part of Python for Data Work. It assumes what came before it and leads directly into the next lesson in the module.

In this lesson you will

  • Read and write files safely with context managers
  • Parse CSV data and handle encoding issues
  • Deal with missing and malformed rows on load

Resources