Is there a way to import a csv file into a postgres 9.1 table in a way that columns
in the csv file that have no data will be in the postgres table as blanks instead of single quotes?
Here are the details..
my csv file looks like this:
firstname,middlename,lastname,jr
"John","M","Smith","III"
"Mary","","Smith",""
My table columns look like this:
firstname character varying (25),
middlename character varying (15),
lastname character varying (25),
jr character varying (4)
My copy statement looks like this:
COPY akamaitest FROM 'C:\Program Files (x86)\PostgreSQL\9.1\data\akamaitest.CSV' WITH (FORMAT 'csv', HEADER, NULL '');
The import works perfectly except that the columns for Mary that have no data (middlename and jr) contain two single quotes: ''
I'm trying in vain to modify my copy statement and my table schema so the columns that have no data show up in the table as blanks not quotes.
I've also tried altering the table columns for middlename and jr by adding the NULL keyword like this:
middlename character varying (15) NULL,
But that made no difference, the two single quotes still are placed into the columns with no data.
Any suggestions would be really appreciated.