Imagine you have a CSV file with only text in it and line ending \r\n
.
like this:
abc
def
hij
...
xyz
You want to import this file in an existing multi-column table, where each line of text needs to go in a line of one specific (currently empty) column (lets name it needed
) of the table. Like this:
| a | b | c |needed|
|foo|bar|baz|______|
<-- abc
|foo|bar|baz|______|
<-- def
...
|foo|bar|baz|______|
<-- xyz
The data from the CSV file does not need to be inserted in a certain order. It really does not matter which field of needed
has which data from the CSV in it, as long as every line gets imported, everything is fine.
I've tried lots of things and its driving me mad, but I can't figure out, how this could be done. Can this be solved somehow with LOAD DATA INFILE and update/replace/insert command? What would you do in a case like this? Is it even possible with mysql? Or do I need a custom php script for this?
I hope the question is clear enough. Please ask, if something is unclear to you.