I have a csv file I fetch from an API and want to load into a MySQL table, I am unsure what to search for to deal with the unusual nature of the file.
CSV looks something like:
meta data
Class 1
1,2,3
5,9,7
Class 2
2,5,4
6,5,4
Class 3
8,4,3
7,8,8
I would like the output to be something I can load more easily:
Class 1,1,2,3
Class 1,5,9,7
Class 2,2,5,4
Class 2,6,5,4
Class 3,8,4,3
Class 3,7,8,8
I'm used to API's returning json's and looping through it in PHP to load the data. This API only has a csv option - the classes always come through in the same order, so i'm thinking maybe a do until loop to append the first value and just repeating it after it runs into the next line which contains 'Class' then rinse and repeat. Not sure if there is an easier way to go about it.