Skip to main content
PYSPARK • LESSON 17

Reading CSV Files

How do we load raw CSV customer data from disk into a distributed DataFrame?

Beginner2 Minutes150 XP
🤔 THE QUESTION

How do we load raw CSV customer data from disk into a distributed DataFrame?

💡 WHAT IS IT?

spark.read.csv() reads text files formatted with comma-separated values into a Spark DataFrame.

🎯 WHAT IS IT USED FOR?

Ingesting raw data feeds, customer exports, and legacy database dump files into the data lake.

💻 EXAMPLE
customers_df = spark.read.csv("data/customers.csv")

🎯 Mission Objectives

Practice typing production-grade PySpark code for Reading CSV Files.

  • Use spark.read.csv reader API
  • Specify file path location
  • Instantiate raw CSV DataFrame