Skip to main content

Vsql Output in .xlsx

  • October 31, 2015
  • 5 replies
  • 19 views

VC_
Forum|alt.badge.img+1
  • Participating Frequently

Hi,

 

Can any one help me what is the sentx to get data in .xlsx format thru vql.

 

thanks! 

5 replies

Adrian_Oprea_1
Forum|alt.badge.img+1
  • Participating Frequently
  • November 1, 2015

 Why don`t you create an ODBC connection to your Vertica database and then connect form Excel to your db ! 


VC_
Forum|alt.badge.img+1
  • Author
  • Participating Frequently
  • November 2, 2015

I need to create a cron job (In Linux) and send that output to users.

 

 


Adrian_Oprea_1
Forum|alt.badge.img+1
  • Participating Frequently
  • November 4, 2015

Here is some idea that might work for you.

- export the content of the data into csv format, any separetor would work.

- here i use | , the trick is the "sep=|"  (it tell what is your delimiter)make sure you have this as the first line of the file, so when they open it in excel all should be aligned. 

vsql -U dbadmin -w password -F $'|' -At -c "SELECT * FROM table_name"  > '/tmp/bla.csv'
sed -i '1s/^/sep=|\n/' /tmp/bla.csv

The sed command will add the delimiter as the first line in the file.

 

 

 This should do the trick :).

 


VC_
Forum|alt.badge.img+1
  • Author
  • Participating Frequently
  • November 4, 2015

Wow Superb!..


Adrian_Oprea_1
Forum|alt.badge.img+1
  • Participating Frequently
  • November 4, 2015

 Happy to hear this helped :). 

You might wanna cleanup the last row of the files since is going to show the number of rows.