Skip to main content

tab delimited output with vsql on windows ?

  • July 11, 2017
  • 6 replies
  • 8 views

Dave_W

This is driving me nuts today. How do you set the delimiter to tab when spooling out to a file with vsql on windows ? I've tried giving all sorts of values to the -F option but can't get it to work. vsql is interpreting the what I give as literals e.g. if I give -F /t it makes the delimiter in the outout /t, -F '/t' makes it '/t' and -F E'\t'.
Any clue ?
Thanks
Dave

6 replies

TomM
Forum|alt.badge.img
  • Participating Frequently
  • July 11, 2017

Hi. I don't know if this will help, and I recently spoke with the team that works on vSQL. Some of the behavior of vSQL is determined by the tecla library (see http://www.astro.caltech.edu/~mcs/tecla/) Take a look and see if it helps. I'd love to know what you find out. Additionally, perhaps there's a different answer regarding the behavior you're experiencing. I can ask, if you like.


Jim_Knicely
Forum|alt.badge.img+2
  • Participating Frequently
  • July 11, 2017

I think you can do it like this:

[dbadmin@s18384357 ~]$ vsql -Atc "SELECT * FROM jim;"
val1|val2

[dbadmin@s18384357 ~]$ vsql -F $'\t' -Atc "SELECT * FROM jim;"
val1    val2

Jim_Knicely
Forum|alt.badge.img+2
  • Participating Frequently
  • July 11, 2017

Sorry, I see now that you were asking about Windows.

Here is how you can do it there:

C:\Program Files\Vertica Systems\VSQL64>vsql -h verticademos.com -U dbadmin -Atc "select * from jim;"
val1|val2

First, switch off the "tab" auto complete:

C:\Program Files\Vertica Systems\VSQL64>cmd /f
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

Now I can use the TAB key as a value for the delimiter:

C:\Program Files\Vertica Systems\VSQL64>vsql -F "[tab]" -h verticademos.com -U dbadmin -Atc "select * from jim;"
val1    val2

Note that [tab] was me actually hitting the tab key...

Or you can create a variable that hold the tab:

C:\Program Files\Vertica Systems\VSQL64>set tab=[tab]

C:\Program Files\Vertica Systems\VSQL64>vsql -F "%tab%" -h verticademos.com -U dbadmin -Atc "select * from jim;"
val1    val2

Again, [tab] was me actually hitting the tab key...


BenKolt
  • New Participant
  • September 7, 2017

I found that the order in the command line makes a difference. I'm on Win 7 64-bit/VSQL64 8.1 and had to move the -F "[tab]" to the end of the line to keep vsql/Windows from complaining and ignoring everything in the line after the -F "[tab]"


gzzz
Forum|alt.badge.img
  • Participating Frequently
  • March 11, 2024

After seven years there is still no way to pass the separator in the windows command-line?..


Bryan_H
Forum|alt.badge.img+2
  • Participating Frequently
  • March 14, 2024

A workaround example: Create the following "test.sql" file:
\pset fieldsep '\t'
select * from nodes;
Then run: .\vsql.exe -h 192.168.1.1 -U dbadmin -w password -Atf .\test.sql