0

I am getting the above error in my code. encoding=latin-1 needs to be included as a parameter somewhere in select-object-content. Since I am new to this, I am not sure, where to add it.

Can anyone help me in this?

Code:

        client = boto3.client('s3',aws_access_key_id,aws_secret_access_key',region_name)
        resp = client.select_object_content(
        Bucket='mybucket',
        Key='path_to_file/file_name.gz',
        ExpressionType='SQL',
        Expression=query,
        InputSerialization = {'CSV': {"FileHeaderInfo": "Use"}, 'CompressionType': compressionType},
        OutputSerialization = {'CSV': {}},
        )

Traceback:

ClientError                               Traceback (most recent call last)
C:\path/3649752754.py in <module>
     78         Expression=SQL,
     79         InputSerialization = {'CSV': {"FileHeaderInfo": "Use"}, 'CompressionType': compression},
---> 80         OutputSerialization = {'CSV': {}},
     81         )
     82 
ClientError: An error occurred (InvalidTextEncoding) when calling the SelectObjectContent operation: UTF-8 encoding is required. The text encoding error was found near byte 90,112.
Beginner
  • 143
  • 1
  • 12

1 Answers1

0

You need to save your CSV file with UTF-8 encoding. For example, with Notepad++ or Excel->Save As->Select from the dropdown.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 09 '21 at 12:46