Loading compressed files

Moderator: NorbertKrupa

Post Reply
User avatar
nnani
Master
Master
Posts: 302
Joined: Fri Apr 13, 2012 6:28 am
Contact:

Loading compressed files

Post by nnani » Mon Jul 29, 2013 3:01 pm

Hello All,

I was trying to load compressed files using Vertica copy statement

It says cannot read file.
The file has been compressed like this

Code: Select all

compress file_name.txt
After compression file is like this file_name.Z

Vertica is not loading .Z files. Nor we have this option in the COPY statement for loading these files.

Is there any way we can achieve this?
nnani........
Long way to go

You can check out my blogs at vertica-howto

harryrundles
Intermediate
Intermediate
Posts: 96
Joined: Thu Jul 19, 2012 12:33 am

Re: Loading compressed files

Post by harryrundles » Tue Jul 30, 2013 3:52 pm

Hi,

I believe that compress is an older compression utility. Linux typically uses gzip or bzip.

I tried installing the compress and uncompress utilities on my CentOS box using the command "yum install ncompress". It worked, but when I try to compress a file using the compress command, it doesn't do anything.

I think gunzip can decompress a .Z file. Maybe you can decompress using gunzip and then gzip the file? Have you tried simply renaming the .Z file to use a .gz extension and then try to load it?

Also, from the docs, it says that the COPY LOCAL command can load "compressed" files. I don;t know if that is referring to files compressed with the compressed command or not...

Here is a quote from the SQL Manual:
COPY LOCAL loads data in a platform-neutral way. The COPY LOCAL statement loads all files from a local client system to the HP Vertica host, where the server processes the files. You can copy files in various formats: uncompressed, compressed, fixed-width format, in bzip or gzip format, or specified as a bash glob.
Maybe try a COPY LOCAL?

Good luck!
Thanks,
Harry

User avatar
nnani
Master
Master
Posts: 302
Joined: Fri Apr 13, 2012 6:28 am
Contact:

Re: Loading compressed files

Post by nnani » Thu Aug 01, 2013 7:31 am

Hi harry,

I was trying with COPY from local option previously,
This doesn't seem to work.
The three option provided by Vertica are GZIP, BZIP and uncompressed.
I tried it with uncompressed option, but this doesn't work.
nnani........
Long way to go

You can check out my blogs at vertica-howto

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

Re: Loading compressed files

Post by id10t » Thu Aug 01, 2013 10:46 am

Hi!

1. You can use in zcat + copy from stdin
2. znew to recompress .Z files to .gz files


Example of zcat:

Code: Select all

daniel@synapse:~$ file data.Z 
data.Z: compress'd data 16 bits

Code: Select all

daniel@synapse:~$ zcat data.Z 
1|foo|bar
2|egg|etc

Code: Select all

daniel@synapse:~$ vsql -c "create table foo (id int, c1 char(3), c2 char(3))"
CREATE TABLE
daniel@synapse:~$ zcat data.Z | vsql -c "copy foo from stdin direct abort on error"
daniel@synapse:~$ vsql -c "select * from foo"
 id | c1  | c2  
----+-----+-----
  1 | foo | bar
  2 | egg | etc
(2 rows)

User avatar
nnani
Master
Master
Posts: 302
Joined: Fri Apr 13, 2012 6:28 am
Contact:

Re: Loading compressed files

Post by nnani » Thu Aug 01, 2013 1:25 pm

Thanks Skwa,

This looks a good solution. :)
nnani........
Long way to go

You can check out my blogs at vertica-howto

Post Reply

Return to “Vertica Data Load”