I have a CSV file:
name;categories;data
019;07:50:00;0,0
017;07:50:00;0,8
019;07:55:00;0,4
017;07:55:00;1,3
019;08:00:00;0,8
017;08:00:00;1,9
I would like to convert it using PHP into a JSON file according to the following scheme (for a Highcharts diagram):
{
"xAxis":
{
"categories": ["07:50:00","07:55:00","08:00:00"]
},
"series":
[
{
"name": "019",
"data": [0.0,0.4,0.8]
},
{
"name": "017",
"data": [0.8,1.3,1.9]
}
]
}
Explanation:
The rows of the CSV file alternate with data records, here: 019 and 017 (column: 'name'). There can also be more than two data records, this is not fixed. Every five minutes (column: 'categories') the value changes (column: 'data').
I think this is done with the programming method called 'control break'. Can anyone show me an approach to how it could work?