[New-bugs-announce] [issue45009] Get last modified date of Folders and Files using pathlib module

Gopesh Singh report at bugs.python.org
Thu Aug 26 02:34:58 EDT 2021


New submission from Gopesh Singh <gopeshsingh0994 at gmail.com>:

I am trying to get Last modified dates of Folders and Files mounted on Azure Databricks.
I am using following Code:

```
root_dir = "/dbfs/mnt/ADLS1/LANDING/parent"

def get_directories(root_dir):

    for child in Path(root_dir).iterdir():

        if child.is_file():
            print(child, datetime.fromtimestamp(getmtime(child)).date())
      
        else:
            print(child, datetime.fromtimestamp(getmtime(child)).date())
            get_directories(child)
```
The issue is that it is giving wrong dates for some folders.
When I put a wait time of 1 second (time.sleep(.000005)) for each iteration, it gives correct results.
Otherwise, it sometimes give current date or date of folder listed from last iteration.

Seems, when the processing is fast, it is not able to pick correct modified date.

I have explained this issue on other portal: 
https://stackoverflow.com/questions/68917983/get-last-modified-date-of-folders-and-files-in-azure-databricks

----------
components: Library (Lib)
messages: 400312
nosy: gopeshsingh
priority: normal
severity: normal
status: open
title: Get last modified date of Folders and Files using pathlib module
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45009>
_______________________________________


More information about the New-bugs-announce mailing list