Is it possible to loop through Amazon S3 bucket and count the number of lines in its file/key using Python?
<p>Is it possible to loop through the file/key in Amazon S3 bucket, read the contents and count the number of lines using Python?</p>

<p>For Example:</p>

<pre><code>  1. My bucket: "my-bucket-name"
  2. File/Key : "test.txt" 
</code></pre>

<p>I need to loop through the file "test.txt" and count the number of line in the raw file.</p>

<p>Sample Code:</p>

<pre><code>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.
</code></pre>