Glue爬虫和分类器 是否支持UTF16文件编码?

0

【以下的问题经过翻译处理】 你好, AWS Glue 抓取器与 CSV 和 XML 分类器配合使用时,对于 UTF-8 编码的文件效果很好,但对于 UTF-16 编码的文件却不好用。

公共文档没有明确说明这一点:

  • Glue 抓取器和分类器是否支持 UTF-16?
  • 是否有关于 Glue 抓取器和分类器支持的编码的可用文档?

祝好,

Nicolas.

profile picture
EXPERTE
gefragt vor 5 Monaten22 Aufrufe
1 Antwort
0

【以下的回答经过翻译处理】 目前,Glue只支持UTF-8编码的文件[1]。如果传入UTF-16文件,则可能会遇到“内部服务异常”错误消息。最可行的方法是,在通过Glue Crawler之前,通过编程方式将utf-16文件转换为utf-8,以下是使用Python编程语言进行转换的例子:

Specify the file paths

input_file_path = 'input_file.txt' output_file_path = 'output_file.txt'

Open the input file with UTF-16 encoding

with open(input_file_path, 'r', encoding='utf-16') as input_file: # Read the content of the input file content = input_file.read()

Open the output file with UTF-8 encoding

with open(output_file_path, 'w', encoding='utf-8') as output_file: # Write the content to the output file output_file.write(content)

[1] - https://docs.aws.amazon.com/glue/latest/dg/components-key-concepts.html

profile picture
EXPERTE
beantwortet vor 5 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen