[英]How to get latest folder path from S3 using python
I have multiple s3 file paths which contain the folder name as date.我有多个 s3 文件路径,其中包含文件夹名称作为日期。 I want to extract the latest path from S3 using python and boto3 based on the date.
我想根据日期使用 python 和 boto3 从 S3 中提取最新路径。
For Example- Below are the few paths I have under my root folder(s3:///all/stage/servicenow/service-mgmt/sm_task/raw/) Sample Paths -例如-以下是我的根文件夹下的几个路径(s3:///all/stage/servicenow/service-mgmt/sm_task/raw/)示例路径-
all the above paths are in s3:///all/stage/pqr/xyz/abc/raw/YYYY/MM/DD/HH/mm/file.parquet format以上所有路径均采用 s3:///all/stage/pqr/xyz/abc/raw/YYYY/MM/DD/HH/mm/file.parquet 格式
So I need the latest timestamp path under root path (s3:///all/stage/pqr/xyz/abc/raw/) which is s3:///all/stage/pqr/xyz/abc/raw/2020/12/12/11/10/file.parquet.所以我需要根路径(s3:///all/stage/pqr/xyz/abc/raw/)下的最新时间戳路径,即 s3:///all/stage/pqr/xyz/abc/raw/2020/ 12/12/11/10/file.parquet。
How can i achieve this using python and Boto3.我如何使用 python 和 Boto3 来实现这一点。
Any help will be appreciated as I am new in python任何帮助将不胜感激,因为我是 python 的新手
Please comment if the question is not clear如果问题不清楚,请发表评论
from os import path
is one way to check the file using function是使用 function 检查文件的一种方法
os.path.splitext(root,date)
and just use your own algorithm to check weather or not your file time is the newest并且只需使用您自己的算法来检查天气或您的文件时间是否是最新的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.