【问题标题】:Export SQL result to CSV but retain the newline values in fields将 SQL 结果导出到 CSV,但保留字段中的换行值
【发布时间】:2017-09-28 02:59:22
【问题描述】:
我正在尝试通过 Sequel Pro 将查询结果导出到 CSV,并且我想保留其换行值。
我尝试使用REPLACE() 进行转义,也尝试使用其他终结符,例如;。
我的内容是这样的
“喜欢”这个词的意思是深深地爱着某样东西。其他与 adore 意思相同的词是
“珍惜,珍惜,深爱”
如何将这些数据导出到保留换行符的 CSV?
请注意,are 后面有一个whitespace 字符,后跟换行符。
【问题讨论】:
标签:
mysql
csv
export-to-csv
sequelpro
【解决方案1】:
如果我没记错的话,你可以选择使用逗号作为分隔符,在字符串的前面和结尾用 " 括起整个字符串内容,在你的字符串中用 "" 转义,这样你就可以保留你的换行内容。
例如,代替:
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