Importing Nulls from a CSV with COPY FROM

Hi

How should we represent null values in a CSV file so that we can import the file using the COPY FROM command?

I’ve tried several alternatives but none of them seem to work.

Regards

Mark

Hi @mforster ,

just don’t put anything between the commas.
e.g.

col1,col2,col3
1,"text","longer text2"
2,,"longer text2"
3,"text",

Regards
Georg

Hi Georg

Thanks for your response.

yes it works with character columns, but we want to be able to support null values in numeric columns.

If we leave a space in a numeric column (i.e. via 2 commas , ) the data loads but we get an error when we query the table.

Regards

Mark

@mforster

Is it maybe the same issue as https://github.com/crate/crate/issues/10563 ?
What client are you using for your testing?

image
image

val,tex
1,"Hello"
2,
,"World"
CREATE TABLE IF NOT EXISTS "doc"."nullvalues" (     
    "val" INTEGER,                                   
    "tex" TEXT                                       
 ) 

Hi Georg

Yes we are seeing very similar issues in crash and the .Net client when using the “COPY FROM” command with nulls in numeric fields.

The data loads OK but when we try to query the table we get “null string” errors.

Regards

Mark

Ok, this seems like some sort of bug then.
I will have someone from engineering look into it.

regards
Georg

Cheers thanks

Regards

Mark