FileModifiedTime¶
Bases: BaseFileFilter, FrozenModel
Filter files matching a specified modification time.
If file modification time (.stat().st_mtime) doesn't match range, it will be excluded.
Doesn't affect directories or paths without .stat() method.
Note
Some filesystems return timestamps truncated to whole seconds (without millisecond part).
since and until values should be adjusted accordingly.
Added in 0.13.0
Parameters:
-
since(datetime) –Minimal allowed file modification time.
Nonemeans no limit. -
until(datetime) –Maximum allowed file modification time.
Nonemeans no limit.
Examples:
Select files modified between start of the day (`00:00:00``) and hour ago:
from datetime import datetime, timedelta
from onetl.file.filter import FileModifiedTime
hour_ago = datetime.now() - timedelta(hours=1)
day_start = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
file_mtime = FileModifiedTime(since=day_start, until=hour_ago)
from datetime import datetime, timedelta
from onetl.file.filter import FileModifiedTime
hour_ago = datetime.now() - timedelta(hours=1)
file_mtime = FileModifiedTime(since=hour_ago)
match(path)
¶
Returns True if path is matching the filter, False otherwise
Added in 0.8.0
Examples:
>>> from onetl.impl import LocalPath
>>> filter.match(LocalPath("/path/to/file.csv"))
True
>>> filter.match(LocalPath("/path/to/excluded.csv"))
False
>>> filter.match(LocalPath("/path/to/file.csv"))
True