Copy from CSV file to a Integer Column

Moderator: NorbertKrupa

Post Reply
avenirit
Newbie
Newbie
Posts: 2
Joined: Mon Nov 26, 2012 3:38 pm

Copy from CSV file to a Integer Column

Post by avenirit » Mon Nov 26, 2012 3:43 pm

Hello All,

I have someting like this

Create Table Sample(
column 1 bigint,
column 2 varchar,
column 3 varchar)

Data is

, test1,test2 (note that first column is null)

Copy command gives me error saying that invalid value for column integer, my copy command is
copy schema.Sample from 'Table1.csv' delimiter ',' null as '' exceptions '/aim/pmmcdicsvfiles/exception.txt' ;

User avatar
JimKnicely
Site Admin
Site Admin
Posts: 1825
Joined: Sat Jan 21, 2012 4:58 am
Contact:

Re: Copy from CSV file to a Integer Column

Post by JimKnicely » Mon Nov 26, 2012 3:58 pm

Hi avenirit ,

Welcome to the forums!

Your example works okay when I try:

Code: Select all

dbadmin=> \! cat /usr/home/dbadmin/Table1.csv;
, test1,test2
dbadmin=> create table sample (
dbadmin(>   column1 bigint,
dbadmin(>   column2 varchar,
dbadmin(>   column3 varchar);
CREATE TABLE
dbadmin=> copy Sample from '/usr/home/dbadmin/Table1.csv' delimiter ',' null as '' exceptions '/usr/home/dbadmin/exception.txt';
 Rows Loaded
-------------
           1
(1 row)

dbadmin=> select * from sample;
 column1 | column2 | column3
---------+---------+---------
         |  test1  | test2
(1 row)
Hmm.
Jim Knicely

Image

Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.

avenirit
Newbie
Newbie
Posts: 2
Joined: Mon Nov 26, 2012 3:38 pm

Re: Copy from CSV file to a Integer Column

Post by avenirit » Mon Nov 26, 2012 7:32 pm

Hi

I figured out the problem

my csv file looked like this

, ,test1 ,test2

Once I deleted the extra whitespace it is working now.

Thanks for your help

User avatar
JimKnicely
Site Admin
Site Admin
Posts: 1825
Joined: Sat Jan 21, 2012 4:58 am
Contact:

Re: Copy from CSV file to a Integer Column

Post by JimKnicely » Mon Nov 26, 2012 8:32 pm

No problem!
Jim Knicely

Image

Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.

Post Reply

Return to “Vertica Data Load”