vsql Export to CSV from commandline

Moderator: NorbertKrupa

Post Reply
ajit_nayak
Newbie
Newbie
Posts: 15
Joined: Tue May 14, 2013 1:25 pm

vsql Export to CSV from commandline

Post by ajit_nayak » Thu Jul 31, 2014 8:45 am

Hi,

I have an issue with csv export (dump) for a query result in vertica.

i.e. for a column string containing comma is splitting into another column for which data is mismatching

example :

(Required OutPut)
_____________________________
ID NAME SALARY
-- ------ ------
1 AK,Nayak 100000

(Actual Output)
_____________________________
ID NAME SALARY
-- ---- ------
1 AK Nayak 100000

Commands Used for export to csv through commandline :
--------------------------------------------------------------------
/opt/vertica/bin/vsql -w <password> -P footer=off -F$',' -A -o "/home/dbadmin/test.csv" -c "SELECT * from Table LIMIT 100 ;"


Please someone help me in getting the required csv file with quoted identifier .

Thanks
Ajit Kumar Nayak
ajit.nayak@vichara.com

id10t
GURU
GURU
Posts: 732
Joined: Mon Apr 16, 2012 2:44 pm

Re: vsql Export to CSV from commandline

Post by id10t » Thu Jul 31, 2014 5:16 pm

Hi!

[DELETED]
Last edited by id10t on Wed May 06, 2015 5:09 pm, edited 1 time in total.

ajit_nayak
Newbie
Newbie
Posts: 15
Joined: Tue May 14, 2013 1:25 pm

Re: vsql Export to CSV from commandline

Post by ajit_nayak » Fri Aug 01, 2014 11:11 am

Thanks for Reply.

I checked with the command you have given , But I found '-o' command in my commandline arguments is generatiing the wrong file.

If I am redirecting the output to a location ,then the file is OK.

e.g .

/opt/vertica/bin/vsql -w <pwd> -F$'","' -P footer=off -A -c "Select * from Ajit" | sed 's/^\|$/"/g' > /home/dbadmin/test.csv

But in -o command the data is like below :

id","name","salary
1","Ak Nayak","10000
2","Daniel Leybovich","500



How can I make it work with ' -o ' command , Please suggest.

Thanks
Ajit

Post Reply

Return to “vSQL”