将 SQL 结果导出为 CSV 但保留字段中的换行值
Export SQL result to CSV but retain the newline values in fields
我正在尝试通过 Sequel Pro 将查询结果导出到 CSV 中,我想保留其换行值。
我尝试使用 REPLACE()
进行转义,我也尝试使用其他终止符,例如 ;
.
我的内容是这样的
The word "adore" means to love something deeply. Other words that mean the same as adore are
"cherish, treasure, love dearly"
如何将此数据导出到 CSV 中并保留换行符?
请注意 后跟一个换行符后有一个 whitespace
字符。
如果我没记错的话,你可以选择逗号作为分隔符,将整个字符串内容用"括在字符串的前后,在你的字符串中用""转义",这样就可以了保留您的新行内容。
例如,而不是:
The word "adore" means to love something deeply. Other words that mean the same as adore are
"cherish, treasure, love dearly"
尝试将上面的内容更改为:
other_content_in_csv,"The word ""adore"" means to love something deeply. Other words that mean the same as adore are
""cherish, treasure, love dearly"" ",other_content_in_csv
我正在尝试通过 Sequel Pro 将查询结果导出到 CSV 中,我想保留其换行值。
我尝试使用 REPLACE()
进行转义,我也尝试使用其他终止符,例如 ;
.
我的内容是这样的
The word "adore" means to love something deeply. Other words that mean the same as adore are "cherish, treasure, love dearly"
如何将此数据导出到 CSV 中并保留换行符?
请注意 后跟一个换行符后有一个 whitespace
字符。
如果我没记错的话,你可以选择逗号作为分隔符,将整个字符串内容用"括在字符串的前后,在你的字符串中用""转义",这样就可以了保留您的新行内容。
例如,而不是:
The word "adore" means to love something deeply. Other words that mean the same as adore are
"cherish, treasure, love dearly"
尝试将上面的内容更改为:
other_content_in_csv,"The word ""adore"" means to love something deeply. Other words that mean the same as adore are
""cherish, treasure, love dearly"" ",other_content_in_csv