title: reading and writing excel files from s3 using boto3 in lambda
body: <p>I'm trying to read an excel file from one s3 bucket and write it into another bucket using boto3 in aws lambda. I've provided full s3 access to my role and have written the following code</p>
  
  <pre><code>import boto3
  import botocore
  import io
  def lambda_handler(event, context):
      s3 = boto3.resource('s3')
      s3.Bucket('&lt;first_bucket&gt;').download_file('&lt;file_name&gt;.xlsx', '/tmp/&lt;file_name&gt;.xlsx')
      object = s3.Object('&lt;first_bucket&gt;','&lt;file_name&gt;.xlsx')
      with open('/tmp/&lt;file_name&gt;', 'wb') as data:
          object.download_fileobj(data)
      target_object =  s3.Object('&lt;second_bucket&gt;','&lt;file_name&gt;.xlsx')
      target_object.put(data)
  
  
      return 'Successfully written to new bucket'
  </code></pre>
  
  <p>I executed this code in Lambda and when I check my second bucket I can see that the file is present but it's size is 0. I'm not sure why and how to correct this. Any pointers?</p>