I have some text file. Which I can't import into a PostgreSQL table because some of my columns have NULL values. My table's columns are of type integer
, bigint
, double precision
.
If all column's data types are character varying
, it imports well. When the above data types are used, I get an error.
sample table
create table if not exists test
(
col1 character varying,
col2 bigint default 0,
col3 integer default 0,
col4 double precision default 0.0,
col5 double precision default 0.0,
col6 character varying,
col7 character varying)
sample text file:
1234||||0.0566|ab3|
1234||||0.0566|ab3|
1234||2||0.0566|ab3|
1234|9465662698|||0.0566|ab3|
This is the command I am using:
copy test.test1 (col1, col2, col3, col4, col5, col6, col7) FROM '/home/tanzir/Documents/test' DELIMITER '|'
I get an error like:
ERROR: invalid input syntax for type bigint: ""
CONTEXT: COPY test1, line 1, column col2: ""
Please help me how to solve it?