将查询结果导出到 .csv 文件时避免 "
avoid " while exporting results of a query into a .csv file
我在数据库中保存了 3 profile_names。在导出给定查询的结果时,我得到 profile_names 包含带双引号的空格,例如"gold plan"。
sqlite> .mode csv
sqlite> .output stdout
sqlite> SELECT profile_name FROM sub_profile_table;
profile_name
arup
"gold plan"
"very gold plan"
是否可以在将查询结果导出到.csv 文件时得到这样的输出?
profile_name
arup
gold plan
very gold plan
CSV 输出模式在需要时引用值。
只要你只有一个列,就可以使用.mode list
。您也可以将它用于多列(使用 .separator ,
),但如果某些值实际上包含逗号,那将会中断。
sqlite> .mode list
sqlite> .separator ,
sqlite> .output out.csv
sqlite> SELECT profile_name FROM sub_profile_table;
我在数据库中保存了 3 profile_names。在导出给定查询的结果时,我得到 profile_names 包含带双引号的空格,例如"gold plan"。
sqlite> .mode csv
sqlite> .output stdout
sqlite> SELECT profile_name FROM sub_profile_table;
profile_name
arup
"gold plan"
"very gold plan"
是否可以在将查询结果导出到.csv 文件时得到这样的输出?
profile_name
arup
gold plan
very gold plan
CSV 输出模式在需要时引用值。
只要你只有一个列,就可以使用.mode list
。您也可以将它用于多列(使用 .separator ,
),但如果某些值实际上包含逗号,那将会中断。
sqlite> .mode list
sqlite> .separator ,
sqlite> .output out.csv
sqlite> SELECT profile_name FROM sub_profile_table;