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:ย 

Import excel spreadsheet to a database table

MGraham
New Contributor

How to Import excel spreadsheet to a database table.

2 REPLIES 2

jerrygen78
New Contributor III

Hi MGraham,

To import an Excel spreadsheet into a database table in Databricks, you can first upload the Excel file to DBFS (Databricks File System), then use libraries like pandas to read the Excel file (e.g., pd.read_excel("/dbfs/path/to/file.xlsx")) and convert it to a Spark DataFrame. Once in a DataFrame, you can write it to a database table using .write.format("jdbc") for external databases or .write.saveAsTable("table_name") for internal Databricks tables. Let me know if you'd like a quick code example!

Regards

FedeRaimondi
Contributor

An alternative is also to store the flat file into a Volume in Unity Catalog. You can then access it in a similar way:

 

import pandas as pd

volume_path= "/Volumes/<catalog>/<schema>/<volume_folder>/your_file.xlsx"
pd.read_excel(volume_path, sheet_name="your_sheet")

 

 

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local communityโ€”sign up today to get started!

Sign Up Now