How to create a file from output of vertica table query in UTF-8 format?

Hello,

In my shell script, I extract table data from HP Vertica DB into a csv file using vsql -c command. But the problem is the file getting created is in binary format and hence some of the data becomes unreadable which has chinese characters as part of data.

file -i filename.csv - gives charset=binary

Tried converting it into utf-t using

iconv -f binary -t utf-8 input.csv -o output.csv

But it gives error- conversion from binary to utf-8 unsupported.

Is there any way to create the file in utf-8 format by default.

Thanks in advance!

If file does not recognize the format then the result is just an educated guess. binary is not an encoding character set. Run iconv -l to get a list of supported character sets. Not sure about the default settings for vsql -c . Maybe a man or help on vsql will tell you the defaults. If UTF-16 (or any from the list that was used to encode), then use:

iconv -f UTF-16 -t UTF-8 input.csv -o output.csv

Post a hexdump of a few lines / bytes of the file, e.g. od -tx1c input.csv .