Record Separation in VSQL Export; CR LF

236 views Asked by At

I'm exporting using vsql and I've included an explicit ' \pset recordsep '\n' ' in the header.

I'd expect the resulting text file to have just 'LF' at the end of each record, but the records end in 'CRLF' instead, despite the lack of '\r' in the record separator. This is a problem for me, as I need the exported file not to have '\r' characters. I am running Windows.

Has anyone else run into this problem? I couldn't find anything related in the vsql documentation.

1

There are 1 answers

1
woot On BEST ANSWER

I tried using \012 (octal for newline) and it equates that with \n so I don't see a way to do it within vsql.

You could download a program from Sourceforge called dos2unix.exe and pipe it, something like:

vsql -h myserver -U dbadmin -w mypassword -f export.sql | dos2unix.exe > output.txt

Also, a second thought... if you are transferring this output file to a unix server, then instead you can transfer it in ASCII mode which with automatically translate the CRLF for you. Some clients will automatically do it based upon the file extension (usually labeled as Automatic mode), but regardless of the file extension, you should be able to set it specifically for FTP, SFTP or even SCP on some clients. Be aware that for SCP, it will have to convert it BEFORE the transfer due to the SCP protocol requirement of knowing the exact file size before the transfer even starts.