0

我的代码中出现上述错误。encoding=latin-1需要作为参数包含在 select-object-content 的某处。由于我是新手,我不确定在哪里添加它。

任何人都可以帮助我吗?

代码:

        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': {}},
        )

追溯:

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.
4

1 回答 1

0

您需要使用 UTF-8 编码保存 CSV 文件。例如,使用 Notepad++ 或 Excel->另存为->从下拉列表中选择。

于 2021-12-09T08:22:58.567 回答