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 ?

4
  • 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 ? Commented Jan 10, 2017 at 11:37
  • Hi @JoseKilo, did you manage to solve this? Any 2018 updates? Commented Sep 6, 2018 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) stackoverflow.com/a/2675493/2452074 But I think I already tried that back in the day. Commented Sep 6, 2018 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"] Commented Aug 25, 2022 at 2:05

1 Answer 1

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

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

Comments

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.