I am using a macro to create a CSV file from a table.
In the table, the name field is showing as Lastname,Firstname.
In the CSV file, the name field is showing as “Lastname,Firstname” with the slash right before the comma.
(name changed for security)
What do I need to do to get rid of the slash? Does anyone know why it is showing? This is the only field that contains a comma but future changes may include other fields that include commas.
If you’re using Snowflake, it looks like you’re encountering the default behavior of
ESCAPE_UNENCLOSED_FIELD (https://docs.snowflake.com/en/sql-reference/sql/copy-into-location#format-type-options-formattypeoptions|docs), which adds a backslash to escape instances of the
FIELD_DELIMITER in your data.
@Owen originally posted this reply in Slack. It might not have transferred perfectly.
Thank you !
By adding ESCAPE = ’ ’ to the file_format, it replaced the slash with a space. I tried to use ‘’ (null) but that didn’t work.
The issue now is the additional spaces in a string field that I don’t want.
Here is the latest code that eliminates all the extra spaces in the string fields.
However, the result is double commas in the name field.
Example: (name changed for security)
I have tried to use ESCAPE = ‘’ (null) but that gives an error.
Has anyone successfully created a csv file without double commas ?