I have a csv file I need to import into my db.
Sample input:
122545;bmwx3;new;red,black,white,pink
I want the final output to be like this:
INSERT INTO myTable VALUES ("122545", "bmwx3", "new", "red");
INSERT INTO myTable VALUES ("122545", "bmwx3", "new", "black");
INSERT INTO myTable VALUES ("122545", "bmwx3", "new", "white");
INSERT INTO myTable VALUES ("122545", "bmwx3", "new", "pink");
The 4th element is a "sub-csv" with an unknown amount of entries. But always in that format (no ")
Ideally I would like to do this in notepad++ using regex, if not possible I will have to cook up a script.
I think that first I need to make this:
122545;bmwx3;new;red,black,white,pink
Look like this:
122545;bmwx3;new;red
122545;bmwx3;new;black
122545;bmwx3;new;white
122545;bmwx3;new;pink
My problem is that I don't know to match the sub-csv. Is it even possible to do this in pure regex (no programming needed)?
,
with122545;bmwx3;new;