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: 

Python spark.read.text Path does not exist

rba76
New Contributor

Dear all,

I want to read files with python from a storage account. I followed this instruction https://docs.microsoft.com/en-us/azure/azure-databricks/store-secrets-azure-key-vault.

This is my python code:

dbutils.fs.mount(source = "wasbs://container1@datalake1.blob.core.windows.net", mount_point = "/mnt/container1", extra_configs = {"fs.azure.sas.container1.datalake1.blob.core.windows.net":dbutils.secrets.get(scope = "secretscope", key = "secret")})

df = spark.read.text("mnt/container1/helloworld.txt")

df.show()

The mount part runs succesfull, but it is not possible to read the file which is located in the container. I got this error "AnalysisException: 'Path does not exist: dbfs:/mnt/container1/helloworld.txt;'".

Is this a security reason?

Any help would be appreciated!!! Thank you very much!!

best regards,

Rudolf

2 REPLIES 2

shyam_9
Databricks Employee
Databricks Employee

PRADEEPCHEEKATL
New Contributor II

@rba76​  Make sure helloworld.txt file exists in the container1 folder

I'm able to view the text file using the same commands as follows:

Mount Blob Storage:

dbutils.fs.mount(
  source = "wasbs://sampledata@azure.blob.core.windows.net/Azure",
  mount_point = "/mnt/chepra",
  extra_configs = {"fs.azure.sas.sampledata.azure.blob.core.windows.net":dbutils.secrets.get(scope = "azurestorage", key = "azurestoragekey")})

Access files in your container as if they were local files, for example:

df = spark.read.text("/mnt/chepra/systeminfo.txt")
df.show()

adbtextread.jpg 

Hope this helps.

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