我有这段代码可以将动态帧写入 S3 中的文件,但它也用双引号引起来一些记录。 知道如何禁用此功能吗?
format_options = {"optimizePerformance": True, "separator": "\t"}
glueContext.write_dynamic_frame.from_options(
frame=dyf_frame.coalesce(1),
connection_type="s3",
connection_options={
"path": outpath,
"compression": "gzip",
"groupFiles": "inPartition",
},
format="csv",
format_options=format_options,
)
示例输出.txt.gz:
name
NAME1
"NAME2 NAME2SURNAME"
NAME3
"NAME4 NAME4"
"NAME5 NAME5"
预期输出.txt.gz
name
NAME1
NAME2 NAME2SURNAME
NAME3
NAME4 NAME4
NAME5 NAME5
我尝试搜索此案例,但找不到任何相关来源。我需要删除双引号,因为记录是使用 COPY
加载到 redshift 的copy staging.table(
name
)
from 's3://output.txt.gz'
iam_role 'arn:aws:iam::693485840050:role/test'
delimiter '\t' gzip
IGNOREBLANKLINES
IGNOREHEADER 1
COMPUPDATE ON
NULL AS '\000000000000000000';
将
REMOVEQUOTES
添加到 COPY 查询
copy staging.table(
name
)
from 's3://output.txt.gz'
iam_role 'arn:aws:iam::693485840050:role/test'
delimiter '\t' gzip
IGNOREBLANKLINES
IGNOREHEADER 1
COMPUPDATE ON
REMOVEQUOTES
NULL AS '\000000000000000000';
您还可以将
format_options.quoteChar
设置为 -1
请参阅:https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-format-csv-home.html
摘录:“quoteChar – 指定用于引用的字符。默认为双引号。将其设置为 -1 以完全关闭引用。”