我如何卸载一个 CSV 文件,其中只有非空值用引号引起来,引号是可选的,空值不被引用?

How do I unload a CSV file where only non-null values are wrapped in quotes, quotes are optionally enclosed, and null values are not quoted?

(代表 Snowflake 用户提交)


例如 - ““NiceOne”“LLC”、“罗伯特”、“GoodRX”、“Maxift”、“Brian”、“P、N 和 B”、“Jane”

我已经能够使用创建满足所有这些条件的文件格式,但不是满足所有三个条件的文件格式。

我使用了以下建议:

Your first column is malformed, missing the initial ", it should be: """NiceOne"" LLC"

After fixing that, you should be able to load your data with almost default settings,

COPY INTO my_table FROM @my_stage/my_file.csv FILE_FORMAT = (TYPE =
CSV FIELD_OPTIONALLY_ENCLOSED_BY = '"');

...但是上面的格式returns: returns-

"""NiceOne"" LLC","罗伯特","GoodRX","","Maxift","Brian","P,N and B","Jane"

我不想在空字段周围加上引号。我在找

"""NiceOne"" LLC","Robert","GoodRX","Maxift","Brian","P,N and B","Jane"


有什么推荐吗?

如果您使用以下内容,您将不会在 NULL 字段周围得到引号,但会在 ''(空文本)上得到引号。如果这不适合您,您始终可以连接字段并手动设置结果行的格式。

COPY INTO @my_stage/my_file.CSV
FROM (
  SELECT
    '"NiceOne" LLC' A, 'Robert' B, 'GoodRX' C, NULL D,
    'Maxift' E, 'Brian' F, 'P,N and B' G, 'Jane' H
)
FILE_FORMAT = (
  TYPE = CSV
  FIELD_OPTIONALLY_ENCLOSED_BY = '"'
  NULL_IF = ()
  COMPRESSION = NONE
)
OVERWRITE = TRUE
SINGLE = TRUE