1

From a client I got the following csv file:

font_id, fontstyle1, fontstyle2, fontstyle3
1,2,7
2,3,8
3,1
4,8,7,9

So there is 1 font per row, and each font can belong to multiple font styles. In the DB it will be multiple rows per font. So for instance font 1 will be:

font_id | font_style
1       | 2
1       | 7
2       | 3
2       | 8
3       | 1
4       | 8
4       | 7
4       | 9

So each font has a variable amount of font styles (so a variable amount of rows in the csv.

I have been looking but cant think of the right search phrase to find a solution. Could anyone point me in the right direction

Thanks in advance!

Merijndk
  • 1,674
  • 3
  • 18
  • 35
  • 1
    Hint: unpivot columns – Lukasz Szozda Oct 29 '18 at 15:51
  • 1
    You just need a bit of application code to parse the file. Does the order in which styles appear carry any innate meaning? – Strawberry Oct 29 '18 at 15:57
  • @Strawberry no it doesnt have any meaning. Normally I would write some script in python that would import this data. Just curious if mysql itself could do something like this – Merijndk Oct 29 '18 at 16:09
  • 1
    @LukaszSzozda Thanks for the hint! I found a question that can point me in the right direction: https://stackoverflow.com/questions/15184381/mysql-turn-table-into-different-table and started a vote to close the question – Merijndk Oct 29 '18 at 16:22

0 Answers0