cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to process all Azure storage file from Databricks

bchaubey
Contributor II

Hi,

I want to process all files that are in my azure storage using databricks, What is the process?

2 ACCEPTED SOLUTIONS

Accepted Solutions

-werners-
Esteemed Contributor III

It depends on what you mean by 'process'.
Spark can read several files at once.  All you need is the path to a directory with files.
Then you can read the whole directory using spark.read.parquet/csv/json/... (depends on your file format).

It is important however that all files have the same schema (columns), otherwise this approach will not work.

Is this what you are looking for? Or do you also need help with linking your data lake to databricks?

View solution in original post

bchaubey
Contributor II

in attachment only one file that is 003.csv. Suppose i have 5 files and all schema are same. How can load in dataframe one by one?

View solution in original post

5 REPLIES 5

-werners-
Esteemed Contributor III

It depends on what you mean by 'process'.
Spark can read several files at once.  All you need is the path to a directory with files.
Then you can read the whole directory using spark.read.parquet/csv/json/... (depends on your file format).

It is important however that all files have the same schema (columns), otherwise this approach will not work.

Is this what you are looking for? Or do you also need help with linking your data lake to databricks?

bchaubey
Contributor II

in attachment only one file that is 003.csv. Suppose i have 5 files and all schema are same. How can load in dataframe one by one?

-werners-
Esteemed Contributor III
df = spark.read.csv("/mnt/lake/data/csv")

Here I assume "/mnt/lake/data/csv" is the directory with the 5 files.
spark.read.csv also has some options like the separator, header etc:
https://spark.apache.org/docs/latest/sql-data-sources-csv.html

So there is no need to do this one by one, read the whole dir in one go.

bchaubey
Contributor II

Could you  please provide me the code with my scenario

-werners-
Esteemed Contributor III

well, my previous post kinda is the code.
The dataframe will read all files in this directory.
What else do you need? 

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!