小编Ren*_*evi的帖子

是否可以使用Python遍历Amazon S3存储桶并计算其文件/密钥中的行数?

是否可以在Amazon S3存储桶中循环访问文件/密钥,使用Python读取内容并计算行数?

例如:

  1. My bucket: "my-bucket-name"
  2. File/Key : "test.txt" 
Run Code Online (Sandbox Code Playgroud)

我需要遍历文件“ test.txt”并计算原始文件中的行数。

样例代码:

for bucket in conn.get_all_buckets():
    if bucket.name == "my-bucket-name":
        for file in bucket.list():
            #need to count the number lines in each file and print to a log.
Run Code Online (Sandbox Code Playgroud)

python amazon-s3 boto amazon-web-services

3
推荐指数
1
解决办法
8541
查看次数

标签 统计

amazon-s3 ×1

amazon-web-services ×1

boto ×1

python ×1