title: How to read and validate header in csv uploaded in s3 in aws lambda python function
body: <p>I need to upload CSV data to MySQL. To achieve this, I have utilized the AWS Lambda service. I am reading a CSV file from an S3 bucket in the Lambda function, which uses Python2.7. I want to validate the header of the CSV with values which I inserted in Environment Variables in the Lambda console. However, on printing the data, I am getting '\r' at the end of the value of the last column of each row.</p>
  
  <p>I am able to read the data from CSV, and the values are also getting inserted to the MySQL DB. </p>
  
  <pre><code>def validateCSV(event,context):
      EXPECTED_HEADERS=os.environ['RM_EXPECTED_HEADERS']
      s3 = boto3.client("s3")
      file_obj = event["Records"][0]
      bucketname = str(file_obj['s3']['bucket']['name'])
      filename = str(file_obj['s3']['object']['key'])
      fileObj = s3.get_object(Bucket=bucketname, Key=filename)
      rows = fileObj["Body"].read().split('\n')
      print(rows)//(['Name,Age,PinCode\r', 'Apple,15,411001\r',''])
      fList=[]
      for line in rows:
         fList.append(line.split(','))
      print("fList Headers matched: ",fList[0]==EXPECTED_HEADERS)//this is giving me FALSE
  </code></pre>
  
  <p>I have added value in environment variable --key=RM_EXPECTED_HEADERS and value as ['Name','Age','PinCode'].  But when I am printing fList[0], I am getting (['Name', 'Age', 'PinCode\r']). </p>
  
  <p>How do I remove '\r' from fList[0]?</p>