3

here is a simplified version of my question:

csv file:

| id | colA | colB |
| 1  |      |  1.5 |
| 2  |      |  2.2 |
| 3  |  3.3 |  3.5 |

...

I am trying to perform a "load data local infile" operation, but I keep getting warnings on "colA"'s first two entries: because they are empty strings for DB when the DB read the file.

Is there a way I can replace them during the load data step?

Thank you so much!

1 Answer 1

2

Use a user variable to transform the column

LOAD DATA LOCAL INFILE "filename"
INTO TABLE tablename
(id, @colA, @colB)
SET colA = NULLIF(@colA, ''), colB = NULLIF(@colB, '')
Sign up to request clarification or add additional context in comments.

2 Comments

Also, if you need to do that in multiple lines, do you need "," to separate them out?
For example, SET colA = NULLIF(@colA, ''), colB = NULLIF(@colB, '') Is that right syntax?

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.