Files, formats & storage

Pro lesson Advanced

Reading CSV and JSON

Load messy real-world files and handle what goes wrong.

10 min8 hands-on steps

In this lesson you will

  • Look at a raw file before you load it
  • Read CSV files and check what the reader guessed
  • Handle semicolons, ambiguous dates, N/A and a bad row
  • Read JSON and reach inside nested fields

Words you'll meet

CSV
A plain text file with one row per line and values separated by commas (or another character).
Header
The first line of a CSV file, holding the column names.
Delimiter
The character that separates values on a line: a comma, a semicolon, a tab.
Schema inference
Guessing the columns and their types by reading a sample of the file.
JSON
Text made of "name": value pairs in curly braces, the usual format for app and API data.
Nested
Data inside data: an object inside an object, or a list inside a row.

The steps

Each step teaches one idea, then has you try it hands-on in your browser, and checks your work.

  1. 1Look before you load
  2. 2Let DuckDB guess
  3. 3A different till
  4. 4Whose March?
  5. 5Say what you know
  6. 6One bad row
  7. 7JSON from the app
  8. 8Challenge

This lesson is part of LearnDE Pro

$12 a month or $100 a year: every lesson, spaced-repetition flashcards, and Learn by teaching. Refund on request within 14 days.