Databricks Tutorial: Recursive File Lookup in PySpark (CSV Files)

Опубликовано: 06 Июль 2026
на канале: Data Engineering Toolbox
232
2

YouTube Video Description:
In this video, I'll show you how to use recursive file lookup in Databricks with PySpark. This allows you to read CSV files from a directory and all its subdirectories automatically. You'll learn how to:

Set up a file path for recursive reading.
Automatically detect CSV headers and infer schema.
Add a column to track which file each row came from.
This method is perfect for handling large datasets spread across multiple folders in Databricks.

Code breakdown:

We use the recursiveFileLookup option to read all CSVs in nested directories.
The header and inferSchema options ensure proper data formatting.
We add a file path column to the DataFrame using input_file_name().
Path Example: In this video, we read CSV files from a nested directory: /New-mnt/data/folder1/subfolder/Info.csv.

Don’t forget to like and subscribe for more data engineering tips!