[issue45009] Get last modified date of Folders and Files using pathlib module

2021-08-25 Thread Gopesh Singh


New submission from Gopesh Singh :

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(.05)) 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 
<https://bugs.python.org/issue45009>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45009] Get last modified date of Folders and Files using pathlib module

2021-08-25 Thread Gopesh Singh


Gopesh Singh  added the comment:

Adding further details:

//
from os.path import getmtime
from datetime import datetime
from pathlib import Path
import time
//

System:
Operating System: Ubuntu 18.04.5 LTS
Python: 3.8.8

--

___
Python tracker 
<https://bugs.python.org/issue45009>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45009] Get last modified date of Folders and Files using os.path module

2021-08-26 Thread Gopesh Singh


Gopesh Singh  added the comment:

Updated title. As I used getmtime of os.path module.

--
title: Get last modified date of Folders and Files using pathlib module -> Get 
last modified date of Folders and Files using os.path module

___
Python tracker 
<https://bugs.python.org/issue45009>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45009] Get last modified date of Folders and Files using os.path module

2021-08-26 Thread Gopesh Singh


Gopesh Singh  added the comment:

Thanks Vedram for the response. Changed the title.

But I get the same issue with Path.stat().

When I put a sleep time for each iteration, it works fine. Else, it gives 
current date as modified date.

--

___
Python tracker 
<https://bugs.python.org/issue45009>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com