arup
arup

Reputation: 43

avoid " while exporting results of a query into a .csv file

I have saved 3 profile_names in db. While exporting the results of the given query, i'm getting profile_names containing spaces with double quotes e.g. "gold plan".

    sqlite> .mode csv
    sqlite> .output stdout
    sqlite> SELECT profile_name FROM sub_profile_table;
    profile_name
    arup
    "gold plan"
    "very gold plan"

Is it possible to get the output like this while exporting query results into .csv file?

    profile_name
    arup
    gold plan
    very gold plan

Upvotes: 2

Views: 1512

Answers (2)

Kadeer Canada
Kadeer Canada

Reputation: 11

sqlite> .mode list
sqlite> .separator ,
sqlite> .output out.csv
sqlite> SELECT profile_name FROM sub_profile_table;

Upvotes: 1

CL.
CL.

Reputation: 180270

The CSV output mode quotes values when needed.

As long as you have only a single column, you can use .mode list. You can use this also with multiple columns (with .separator ,), but that would break if some value actually contains a comma.

Upvotes: 4

Related Questions