6

I am importing CSV files into Google Cloud SQL using its import functionality. It allows to import data into a Cloud SQL table.

API reference: https://cloud.google.com/sql/docs/admin-api/v1beta4/instances/import

If I use a CSV row with empty values, like:

,,,,42,,

I am getting 0 values in the SQL table. I would like to get NULL values instead. Is it possible ?

JoseKilo
  • 2,343
  • 1
  • 16
  • 28
  • 1
    Actually, my question applies to several languages and can be replicated using Google Cloud UI alone. So, is a code snippet going to be helpful ? – JoseKilo Jan 10 '17 at 11:37
  • Hi @JoseKilo, did you manage to solve this? Any 2018 updates? – Ary Jazz Sep 06 '18 at 12:01
  • Not really. It's been a while. I think I ended up changing the way I generated my CSVs. Sorry. I would try something like this (I think this functionality is/was based on MySQL LOAD DATA) https://stackoverflow.com/a/2675493/2452074 But I think I already tried that back in the day. – JoseKilo Sep 06 '18 at 15:07
  • Update from 2022 and using postgres w/ CloudSQL. Empty columns are interpreted as null. E.g. `"id",,"some val"` would be copied as `["id", NULL, "some val"]` – Daniel Aug 25 '22 at 02:05

1 Answers1

0

I found it to work using NULL as a field value:

"gid://Customer/10031988754",0,0,"GBP","[]","GB"
"gid://Customer/1003793973310",0,NULL,NULL,"[]","GB"

this was unexpected, since CSV export generates entries with "N as NULL

sonium
  • 918
  • 1
  • 11
  • 25