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 Pass Data to a Databricks App?

adam_mich
New Contributor

I am developing a Databricks application using the Streamlit package. I was able to get a "hello world" app deployed successfully, but now I am trying to pass data that exists in the dbfs on the same instance. I try to read a csv saved to the dbfs but get a file not found error. I am assuming there is a virtual environment being setup during deployment and there is an additional step I need to do to configure the path. Thanks in advance.

4 REPLIES 4

Walter_C
Databricks Employee
Databricks Employee

Hello Adam,

So you are running something similar to:

 import streamlit as st
 import pandas as pd

 # Path to the CSV file in DBFS
 file_path = '/dbfs/path/to/your/file.csv'

 # Read the CSV file
 df = pd.read_csv(file_path)

 # Display the dataframe in Streamlit
 st.write(df)

And it is resulting in this file not found issue?

Yes, exactly. To add more context, the read_csv() line works if I just run it in a notebook with the same path, but it does not work once I try and deploy the application.

Walter_C
Databricks Employee
Databricks Employee

What if you try to list the file using dbutils.fs.ls("dbfs:/mnt/path/to/data") does it list it?

Well, I can't even use dbutils in the app. When I try that, I get a NameError name 'dbutils' is not defined error. Again, this just works in a notebook but not the app.

 

If I try and do this: 

os.listdir('/dbfs/'), it again does not find that directory.

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