Skip to content
Advertisement

script to get the file last modified date and file name pyspark

I have a mount point location which is pointing to a blob storage where we have multiple files. We need to find the last modified date for a file along with the file name. I am using the below script and the list of files are as below:

JavaScript
JavaScript

Advertisement

Answer

If you’re using operating system-level commands to get file information, then you can’t access that exact location – on Databricks it’s on the Databricks file system (DBFS).

To get that on the Python level, you need to prepend the /dbfs to the path, so it will be:

JavaScript

note the [:5] – it’s used to strip the /dbfs prefix from the path to make it compatible with DBFS

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement