cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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
Valued Contributor
Valued Contributor

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.

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.