title: Reading excel file from s3 using pandas in lambda and convert to csv
body: <p>I'm trying to read an excel file from a s3 bucket using python in lambda, do some manipulations using pandas, convert it to csv and putback to same bucket.</p>
  
  <pre><code>import pandas as pd
  import boto3
  import os
  from urllib.parse import unquote_plus
  
      def lambda_handler(event, context):
          s3=boto3.client('s3')
          if event:
  
              file_obj=event['Records'][0]
              bucket = event['Records'][0]['s3']['bucket']['name']
              key = event['Records'][0]['s3']['object']['key'].encode('utf-8')
              filename=unquote_plus(key)
              ----this line throws error "a bytes-like object is required, not 'str': TypeError"
  
              print("Filename:",filename)
              q=(os.path.splitext(os.path.basename(filename))[0]) #read filename
              print(q)
              obj=s3.get_object(Bucket=bucket,Key=filename)
              print(obj['Body'])                       
              pd.read_excel(obj['Body'],index_col=False,header=5,usecols="A,C:M,U")
              df=df[:-1]                             
              df=df.replace(np.nan,'')                
  
              print(df)
              dfcsv = df.to_csv('s3://bucket/sales.csv' ,sep='\t',encoding='utf-8',index=False) #converttocsv
  </code></pre>
  
  <p>This throws the error: </p>
  
  <blockquote>
    <p>Install xlrd >= 1.0.0 for Excel support: ImportError</p>
  </blockquote>
  
  <p>Also this code works perfectly fine in local envrironment but fails in lambda. </p>
  
  <p>I tried to import xlrd but it throws syntax error</p>
  
  <p>Also is there a better way of writing the code for my requirement?</p>