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: 

Unable to locate saved data

dsnde49
Visitor

Hi,

I have been trying to save some processed data using pandas from my databricks notebook.

I have tried two versions, using csv and xlsx. The code for both of them runs without any error, but I'm unable to find the location of the saved data.

for table, df in table_schemas.items():
    df.to_csv(f"{table}.csv", index=False)
 
excel_file_path = "https://xyz/file.xlsx"
with pd.ExcelWriter(excel_file_path) as writer:
    for table, df in table_schemas.items():
        df.to_excel(writer, sheet_name=table, index=False)
 
I know how to save using spark, but trying out this functionality as i need data for multiple sheets and combine them into one excel. any suggestion is appreciated.
Thanks!
1 REPLY 1

hari-prasad
Valued Contributor

hi @dsnde49 ,

When using Python instead of Spark in Databricks, the data you write will be stored in the drivers local storage.

To avoid this, you can utilize the spark-excel jar from Crealytics (Maven Repository: com.crealytics » spark-excel). This tool allows you to read data from individual sheets in an Excel file and combine all sheet dataframes into one dataframe using either Join or Union, depending on the nature of the data. Finally, you can collate the dataframe into a single partition using df.coalesce(1).

You can follow this medium post to refer how to use spark-excel library  How to Read Excel files using pyspark in Databricks? | by Amit Joshi | Medium

 

Regards,
Hari Prasad

 



Regards,
Hari Prasad

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group