I wish to check if at certain location, say /dbfs/FileStore/tables/xyz.json exists or not. If yes, then the method should return true. I checked method in dbutils but doesn't seem to find any. Plus, I cannot mount any location in ADLS. What are the ways and how can I workaround with it ?
Asked
Active
Viewed 2,521 times
1 Answers
1
One way to check is by using dbutils.fs.ls.
Say, for your example.
check_path = 'FileStore/tables/'
check_name = 'xyz.json'
files_list = dbutils.fs.ls(check_path)
files_sdf = spark.createDataFrame(files_list)
result = files_sdf.filter(col('name') == check_name)
Then you can use .count(), or .show(), to get what you want.
For the second question, can you elaborate what you meant by cannot mount?

Spacez
- 77
- 2
- 11
-
1user wanted to know the solution using DButils only, which is specific to DBFS. – venus Nov 05 '19 at 17:09