1

I have a CSV file with following format example:

"MC97898","","","file1.txt","01-APR-2020","01-APR-2020"
"MC97899","","","file2.txt","01-APR-2020","01-APR-2020"
"MC97891","","","file3.txt","01-APR-2020","01-APR-2020"
"MC97892","","","file4.txt","01-APR-2020","01-APR-2020"
"MC97893","","","file.xt","01-APR-2020",
"MC97894","","","file.xt","01-APR-2020","01-APR-2020"
"MC97895","","","file.xt","01-APR-2020","01-APR-2020"
"MC97896","","","file.xt","01-APR-2020",

1.5 billion records

table xx(receipt_number, id, mig_filename, mig_inserted_dt, mig_modified_dt)

I can run copy in psql but can't import CSV with null value on date (mig_modified_dt) using PGAdmin?
1st it complains about unterminated CSV, then invalid syntax for type timestamp, I altered it to date, still invalid syntax. I put two single quote on NULL strings ('') on PGAdmin 4, still error even '\N' even blank, still error.

Can we import in PGAdmin if the blank string comes through as null value on date/timestamp column?

1 Answer 1

3

I was having a somewhat similar issue. I wanted to import a CSV file containing the data for a table in PGAdmin. I kept getting this error:

ERROR: invalid input syntax for type integer: "NULL"

I finally found this link:

PgAdmin Null Strings

In PgAdmin, when you right click on the table name > click Import/Export > enter the criteria, then you can click on the "Columns" tab at the top of the pop-up box. There you'll find where you can enter whatever null values you have. For me my CSV, had the word "NULL" for null values. After I typed in NULL in Null Strings, the data imported successfully. Maybe this could work for you.

Sign up to request clarification or add additional context in comments.

3 Comments

thank you, I tried that last time after posted, and still not work because the column definition on the table declared as not nullable and somehow the data from other database had null. All need to removed data with null (not nullable column) and import it fine.
(If you want line breaks where you put double spaces, follow them with a newline.)
An update. In later versions of pgadmin, the option to set the NULL string is under "Options", not under "Columns"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.