Skip to main content
Commonmark migration
Source Link

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)?

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)?

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)?

Source Link
Cornwell
  • 3.4k
  • 8
  • 52
  • 84

Regex inside group

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)?