Skip to content
Edition NigeriaGlobal
Country: Italy

You are in the Italy edition. Type your country to switch.

Set up your profile

You are learning in the Italy edition, with examples in euros and from Italy.

Financial Data Lab · Lesson 1 of 8

Lab 1: reading CSV files in Python and SQL

A CSV file is the plain-text table most financial data arrives in. This lab shows how to load one into Python with pandas and into a SQLite database, check that it loaded correctly, and catch the usual problems: dates read as text, thousands separators, missing values and duplicated rows.

Advanced10 min read5 steps

This lesson is complete in writing. A video for it is on its way.

What you will learn

  • By the end you can load a CSV file of prices into Python with pandas and into a SQLite database.
  • You can check a loaded table: count its rows, list its columns and their data types, and look at its first and last rows.
  • You can find and fix the common silent errors: dates read as text, thousands separators, blank cells and duplicate rows.
  • You can verify a loaded figure, such as an average close, against a hand calculation.

Key terms in this lesson

CSV file
Comma-separated values: a plain-text file in which each line is a row and commas separate the columns. The most common format for exchanging tables of data.
DataFrame
A table of data in Python's pandas library, with named columns that can each hold a different type, such as dates, text or numbers.

Step 1 of 5

Before you start: tools, data and the rules of the lab

Opening this step…

Step 2 of 5

The sample file

This step opens when you finish the one above.

Step 3 of 5

Loading the file in Python

This step opens when you finish the one above.

Step 4 of 5

Loading the same file into SQLite

This step opens when you finish the one above.

Step 5 of 5

The usual traps and how to catch them

This step opens when you finish the one above.

Key takeaways

The key takeaways open when you finish every step.

Lesson quiz

6 questions. You need 85% to pass.

The quiz opens when you finish every step.

Read first

Stockertim Learn is education. It explains how investing works and never recommends buying or selling anything.

Up next

Financial data & analyticsLab 2: computing returns in codeRead nowLab 2: computing returns in codeFinancial data & analytics · Advanced · 15 minFinancial data & analyticsLab 3: plotting prices and returnsRead nowLab 3: plotting prices and returnsFinancial data & analytics · Advanced · 15 minFinancial data & analyticsLab 4: SQL on a price tableRead nowLab 4: SQL on a price tableFinancial data & analytics · Advanced · 15 minFinancial data & analyticsLab 5: cleaning corporate action…Read nowLab 5: cleaning corporate actions in codeFinancial data & analytics · Advanced · 15 minFinancial data & analyticsFinancial data sourcesRead nowFinancial data sourcesFinancial data & analytics · Intermediate · 15 minFinancial data & analyticsPivot tables for financial dataRead nowPivot tables for financial dataFinancial data & analytics · Intermediate · 15 minInvestment researchResearch data management: reprod…Read nowResearch data management: reproducible models and an audit trailInvestment research · Advanced · 15 minFinancial data & analyticsReading tables, charts and log s…Read nowReading tables, charts and log scalesFinancial data & analytics · Beginner · 15 minFinancial data & analyticsLab 8: writing the model card an…Read nowLab 8: writing the model card and a reproducible notebookFinancial data & analytics · Advanced · 15 minFinancial data & analyticsDashboards and performance repor…Read nowDashboards and performance reports that communicateFinancial data & analytics · Advanced · 15 minFinancial data & analyticsFree against paid data, licensin…Read nowFree against paid data, licensing and terms of useFinancial data & analytics · Intermediate · 15 min
English