How Can I Create CSV File With the coulumn names?

Moderator: NorbertKrupa

Post Reply
sapir azulay
Newbie
Newbie
Posts: 16
Joined: Thu Nov 29, 2012 4:16 pm

How Can I Create CSV File With the coulumn names?

Post by sapir azulay » Wed Dec 05, 2012 1:41 pm

Hi Guys,
How can i crate a csv file wich I can see the column nams too?

Thnaks a lot :)

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

Re: How Can I Create CSV File With the coulumn names?

Post by id10t » Wed Dec 05, 2012 3:40 pm

Hi!

Standard

Code: Select all

[ ~ ]$ vsql -c "select * from foo"
 id | val 
----+-----
  1 | a
  2 | b
  3 | c
(3 rows)
Header:

Code: Select all

[ ~ ]$ vsql -F';' -Ac "select * from foo" | grep -v '([0-9]* rows)'
id;val
1;a
2;b
3;c
Now redirect or add option `-o /path/to/csv_file`

Enclosing

Code: Select all

[ ~ ]$ vsql -F'","' -Ac "select * from foo" | grep -v '([0-9]* rows)' | sed 's/^\|$/"/g'
"id","val"
"1","a"
"2","b"
"3","c"

sapir azulay
Newbie
Newbie
Posts: 16
Joined: Thu Nov 29, 2012 4:16 pm

Re: How Can I Create CSV File With the coulumn names?

Post by sapir azulay » Sun Dec 09, 2012 11:38 am

Thank you :)

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

Re: How Can I Create CSV File With the coulumn names?

Post by id10t » Fri Dec 14, 2012 7:33 pm

UPDATE

Code: Select all

[ ~ ]$ vsql -c "select * from Tripple"
 a  | b  | c  
----+----+----
 69 | 25 | 65
 16 | 24 | 20
  1 | 78 | 67
 18 | 35 | 28
 41 | 87 |  4
 48 | 46 | 80
(6 rows)
and

Code: Select all

[ ~ ]$ vsql -P footer=off -F';' -Ac "select * from Tripple"
a;b;c
69;25;65
16;24;20
1;78;67
18;35;28
41;87;4
48;46;80

khine
Beginner
Beginner
Posts: 33
Joined: Wed Apr 03, 2013 2:54 am

Re: How Can I Create CSV File With the coulumn names?

Post by khine » Thu Apr 18, 2013 2:38 am

Hi may i know how do you get the data before you use the select command?Do you create csv file by yourself ?How ?Thanks

User avatar
Julie
Master
Master
Posts: 221
Joined: Thu Apr 19, 2012 9:29 pm

Re: How Can I Create CSV File With the coulumn names?

Post by Julie » Thu Apr 18, 2013 11:13 pm

khine,

The data is already in the table. skWa is extracting it into a csv file...
Thanks,
Juliette

Post Reply

Return to “Vertica Data Load”