Here ya go:
{ south: [(inputs | split(";")) | {label: .[0], date: .[1], values: .[2] | gsub("[\r]"; "") | tonumber } ] |
group_by(.label) | map({ key: (.[0].label), value: [.[] ] }) | from_entries
}
Yields:
{
"south": {
"watt_hours": [
{
"label": "watt_hours",
"date": "2023-02-21T06:50:00+01:00",
"values": 0
},
{
"label": "watt_hours",
"date": "2023-02-21T07:00:00+01:00",
"values": 161
},
{
"label": "watt_hours",
"date": "2023-02-21T08:00:00+01:00",
"values": 2468
},
{
"label": "watt_hours",
"date": "2023-02-21T09:00:00+01:00",
"values": 6338
},
{
"label": "watt_hours",
"date": "2023-02-21T10:00:00+01:00",
"values": 12598
},
{
"label": "watt_hours",
"date": "2023-02-21T11:00:00+01:00",
"values": 20230
},
{
"label": "watt_hours",
"date": "2023-02-21T12:00:00+01:00",
"values": 27889
},
{
"label": "watt_hours",
"date": "2023-02-21T13:00:00+01:00",
"values": 34942
},
{
"label": "watt_hours",
"date": "2023-02-21T14:00:00+01:00",
"values": 40777
},
{
"label": "watt_hours",
"date": "2023-02-21T15:00:00+01:00",
"values": 44937
},
{
"label": "watt_hours",
"date": "2023-02-21T16:00:00+01:00",
"values": 47227
},
{
"label": "watt_hours",
"date": "2023-02-21T17:00:00+01:00",
"values": 48047
},
{
"label": "watt_hours",
"date": "2023-02-21T17:31:00+01:00",
"values": 48123
},
{
"label": "watt_hours",
"date": "2023-02-22T06:49:00+01:00",
"values": 0
},
{
"label": "watt_hours",
"date": "2023-02-22T07:00:00+01:00",
"values": 242
},
{
"label": "watt_hours",
"date": "2023-02-22T08:00:00+01:00",
"values": 3875
},
{
"label": "watt_hours",
"date": "2023-02-22T09:00:00+01:00",
"values": 9267
},
{
"label": "watt_hours",
"date": "2023-02-22T10:00:00+01:00",
"values": 15664
},
{
"label": "watt_hours",
"date": "2023-02-22T11:00:00+01:00",
"values": 22275
},
{
"label": "watt_hours",
"date": "2023-02-22T12:00:00+01:00",
"values": 28628
},
{
"label": "watt_hours",
"date": "2023-02-22T13:00:00+01:00",
"values": 34258
},
{
"label": "watt_hours",
"date": "2023-02-22T14:00:00+01:00",
"values": 38532
},
{
"label": "watt_hours",
"date": "2023-02-22T15:00:00+01:00",
"values": 41146
},
{
"label": "watt_hours",
"date": "2023-02-22T16:00:00+01:00",
"values": 42415
},
{
"label": "watt_hours",
"date": "2023-02-22T17:00:00+01:00",
"values": 42870
},
{
"label": "watt_hours",
"date": "2023-02-22T17:33:00+01:00",
"values": 42922
}
],
"watt_hours_day": [
{
"label": "watt_hours_day",
"date": "2023-02-21",
"values": 48123
},
{
"label": "watt_hours_day",
"date": "2023-02-22",
"values": 42922
}
],
"watt_hours_period": [
{
"label": "watt_hours_period",
"date": "2023-02-21T06:50:00+01:00",
"values": 0
},
{
"label": "watt_hours_period",
"date": "2023-02-21T07:00:00+01:00",
"values": 161
},
{
"label": "watt_hours_period",
"date": "2023-02-21T08:00:00+01:00",
"values": 2307
},
{
"label": "watt_hours_period",
"date": "2023-02-21T09:00:00+01:00",
"values": 3870
},
{
"label": "watt_hours_period",
"date": "2023-02-21T10:00:00+01:00",
"values": 6260
},
{
"label": "watt_hours_period",
"date": "2023-02-21T11:00:00+01:00",
"values": 7632
},
{
"label": "watt_hours_period",
"date": "2023-02-21T12:00:00+01:00",
"values": 7659
},
{
"label": "watt_hours_period",
"date": "2023-02-21T13:00:00+01:00",
"values": 7053
},
{
"label": "watt_hours_period",
"date": "2023-02-21T14:00:00+01:00",
"values": 5835
},
{
"label": "watt_hours_period",
"date": "2023-02-21T15:00:00+01:00",
"values": 4160
},
{
"label": "watt_hours_period",
"date": "2023-02-21T16:00:00+01:00",
"values": 2290
},
{
"label": "watt_hours_period",
"date": "2023-02-21T17:00:00+01:00",
"values": 820
},
{
"label": "watt_hours_period",
"date": "2023-02-21T17:31:00+01:00",
"values": 76
},
{
"label": "watt_hours_period",
"date": "2023-02-22T06:49:00+01:00",
"values": 0
},
{
"label": "watt_hours_period",
"date": "2023-02-22T07:00:00+01:00",
"values": 242
},
{
"label": "watt_hours_period",
"date": "2023-02-22T08:00:00+01:00",
"values": 3633
},
{
"label": "watt_hours_period",
"date": "2023-02-22T09:00:00+01:00",
"values": 5392
},
{
"label": "watt_hours_period",
"date": "2023-02-22T10:00:00+01:00",
"values": 6397
},
{
"label": "watt_hours_period",
"date": "2023-02-22T11:00:00+01:00",
"values": 6611
},
{
"label": "watt_hours_period",
"date": "2023-02-22T12:00:00+01:00",
"values": 6353
},
{
"label": "watt_hours_period",
"date": "2023-02-22T13:00:00+01:00",
"values": 5630
},
{
"label": "watt_hours_period",
"date": "2023-02-22T14:00:00+01:00",
"values": 4274
},
{
"label": "watt_hours_period",
"date": "2023-02-22T15:00:00+01:00",
"values": 2614
},
{
"label": "watt_hours_period",
"date": "2023-02-22T16:00:00+01:00",
"values": 1269
},
{
"label": "watt_hours_period",
"date": "2023-02-22T17:00:00+01:00",
"values": 455
},
{
"label": "watt_hours_period",
"date": "2023-02-22T17:33:00+01:00",
"values": 52
}
],
"watts": [
{
"label": "watts",
"date": "2023-02-21T07:00:00+01:00",
"values": 1928
},
{
"label": "watts",
"date": "2023-02-21T08:00:00+01:00",
"values": 2686
},
{
"label": "watts",
"date": "2023-02-21T09:00:00+01:00",
"values": 5054
},
{
"label": "watts",
"date": "2023-02-21T10:00:00+01:00",
"values": 7466
},
{
"label": "watts",
"date": "2023-02-21T11:00:00+01:00",
"values": 7797
},
{
"label": "watts",
"date": "2023-02-21T12:00:00+01:00",
"values": 7520
},
{
"label": "watts",
"date": "2023-02-21T13:00:00+01:00",
"values": 6585
},
{
"label": "watts",
"date": "2023-02-21T14:00:00+01:00",
"values": 5084
},
{
"label": "watts",
"date": "2023-02-21T15:00:00+01:00",
"values": 3235
},
{
"label": "watts",
"date": "2023-02-21T16:00:00+01:00",
"values": 1345
},
{
"label": "watts",
"date": "2023-02-21T17:00:00+01:00",
"values": 294
},
{
"label": "watts",
"date": "2023-02-21T17:31:00+01:00",
"values": 0
},
{
"label": "watts",
"date": "2023-02-22T06:49:00+01:00",
"values": 0
},
{
"label": "watts",
"date": "2023-02-22T07:00:00+01:00",
"values": 2637
},
{
"label": "watts",
"date": "2023-02-22T08:00:00+01:00",
"values": 4629
},
{
"label": "watts",
"date": "2023-02-22T09:00:00+01:00",
"values": 6155
},
{
"label": "watts",
"date": "2023-02-22T10:00:00+01:00",
"values": 6639
},
{
"label": "watts",
"date": "2023-02-22T11:00:00+01:00",
"values": 6582
},
{
"label": "watts",
"date": "2023-02-22T12:00:00+01:00",
"values": 6124
},
{
"label": "watts",
"date": "2023-02-22T13:00:00+01:00",
"values": 5135
},
{
"label": "watts",
"date": "2023-02-22T14:00:00+01:00",
"values": 3412
},
{
"label": "watts",
"date": "2023-02-22T15:00:00+01:00",
"values": 1816
},
{
"label": "watts",
"date": "2023-02-22T16:00:00+01:00",
"values": 721
},
{
"label": "watts",
"date": "2023-02-22T17:00:00+01:00",
"values": 189
},
{
"label": "watts",
"date": "2023-02-22T17:33:00+01:00",
"values": 0
}
]
}
}
I could not quite figure out striping the label from the object but just don;t use it, not much data there anyway. I did include stripping \r and converting the values to a number.
Update:
Just change like this:
group_by(.label) | map({ key: (.[0].label), value: [.[] | {date: .date, values: .values}] }) | from_entries
If you want to remove the label:
{
"south": {
"watt_hours": [
{
"date": "2023-02-21T06:50:00+01:00",
"values": 0
},
{
"date": "2023-02-21T07:00:00+01:00",
"values": 161
},
{
"date": "2023-02-21T08:00:00+01:00",
"values": 2468
},
{
"date": "2023-02-21T09:00:00+01:00",
"values": 6338
},
{
"date": "2023-02-21T10:00:00+01:00",
"values": 12598
},
{
"date": "2023-02-21T11:00:00+01:00",
"values": 20230
},
{
"date": "2023-02-21T12:00:00+01:00",
"values": 27889
},
{
"date": "2023-02-21T13:00:00+01:00",
"values": 34942
},
{
"date": "2023-02-21T14:00:00+01:00",
"values": 40777
},
{
"date": "2023-02-21T15:00:00+01:00",
"values": 44937
},
{
"date": "2023-02-21T16:00:00+01:00",
"values": 47227
},
{
"date": "2023-02-21T17:00:00+01:00",
"values": 48047
},
{
"date": "2023-02-21T17:31:00+01:00",
"values": 48123
},
{
"date": "2023-02-22T06:49:00+01:00",
"values": 0
},
{
"date": "2023-02-22T07:00:00+01:00",
"values": 242
},
{
"date": "2023-02-22T08:00:00+01:00",
"values": 3875
},
{
"date": "2023-02-22T09:00:00+01:00",
"values": 9267
},
{
"date": "2023-02-22T10:00:00+01:00",
"values": 15664
},
{
"date": "2023-02-22T11:00:00+01:00",
"values": 22275
},
{
"date": "2023-02-22T12:00:00+01:00",
"values": 28628
},
{
"date": "2023-02-22T13:00:00+01:00",
"values": 34258
},
{
"date": "2023-02-22T14:00:00+01:00",
"values": 38532
},
{
"date": "2023-02-22T15:00:00+01:00",
"values": 41146
},
{
"date": "2023-02-22T16:00:00+01:00",
"values": 42415
},
{
"date": "2023-02-22T17:00:00+01:00",
"values": 42870
},
{
"date": "2023-02-22T17:33:00+01:00",
"values": 42922
}
],
"watt_hours_day": [
{
"date": "2023-02-21",
"values": 48123
},
{
"date": "2023-02-22",
"values": 42922
}
],
"watt_hours_period": [
{
"date": "2023-02-21T06:50:00+01:00",
"values": 0
},
{
"date": "2023-02-21T07:00:00+01:00",
"values": 161
},
{
"date": "2023-02-21T08:00:00+01:00",
"values": 2307
},
{
"date": "2023-02-21T09:00:00+01:00",
"values": 3870
},
{
"date": "2023-02-21T10:00:00+01:00",
"values": 6260
},
{
"date": "2023-02-21T11:00:00+01:00",
"values": 7632
},
{
"date": "2023-02-21T12:00:00+01:00",
"values": 7659
},
{
"date": "2023-02-21T13:00:00+01:00",
"values": 7053
},
{
"date": "2023-02-21T14:00:00+01:00",
"values": 5835
},
{
"date": "2023-02-21T15:00:00+01:00",
"values": 4160
},
{
"date": "2023-02-21T16:00:00+01:00",
"values": 2290
},
{
"date": "2023-02-21T17:00:00+01:00",
"values": 820
},
{
"date": "2023-02-21T17:31:00+01:00",
"values": 76
},
{
"date": "2023-02-22T06:49:00+01:00",
"values": 0
},
{
"date": "2023-02-22T07:00:00+01:00",
"values": 242
},
{
"date": "2023-02-22T08:00:00+01:00",
"values": 3633
},
{
"date": "2023-02-22T09:00:00+01:00",
"values": 5392
},
{
"date": "2023-02-22T10:00:00+01:00",
"values": 6397
},
{
"date": "2023-02-22T11:00:00+01:00",
"values": 6611
},
{
"date": "2023-02-22T12:00:00+01:00",
"values": 6353
},
{
"date": "2023-02-22T13:00:00+01:00",
"values": 5630
},
{
"date": "2023-02-22T14:00:00+01:00",
"values": 4274
},
{
"date": "2023-02-22T15:00:00+01:00",
"values": 2614
},
{
"date": "2023-02-22T16:00:00+01:00",
"values": 1269
},
{
"date": "2023-02-22T17:00:00+01:00",
"values": 455
},
{
"date": "2023-02-22T17:33:00+01:00",
"values": 52
}
],
"watts": [
{
"date": "2023-02-21T07:00:00+01:00",
"values": 1928
},
{
"date": "2023-02-21T08:00:00+01:00",
"values": 2686
},
{
"date": "2023-02-21T09:00:00+01:00",
"values": 5054
},
{
"date": "2023-02-21T10:00:00+01:00",
"values": 7466
},
{
"date": "2023-02-21T11:00:00+01:00",
"values": 7797
},
{
"date": "2023-02-21T12:00:00+01:00",
"values": 7520
},
{
"date": "2023-02-21T13:00:00+01:00",
"values": 6585
},
{
"date": "2023-02-21T14:00:00+01:00",
"values": 5084
},
{
"date": "2023-02-21T15:00:00+01:00",
"values": 3235
},
{
"date": "2023-02-21T16:00:00+01:00",
"values": 1345
},
{
"date": "2023-02-21T17:00:00+01:00",
"values": 294
},
{
"date": "2023-02-21T17:31:00+01:00",
"values": 0
},
{
"date": "2023-02-22T06:49:00+01:00",
"values": 0
},
{
"date": "2023-02-22T07:00:00+01:00",
"values": 2637
},
{
"date": "2023-02-22T08:00:00+01:00",
"values": 4629
},
{
"date": "2023-02-22T09:00:00+01:00",
"values": 6155
},
{
"date": "2023-02-22T10:00:00+01:00",
"values": 6639
},
{
"date": "2023-02-22T11:00:00+01:00",
"values": 6582
},
{
"date": "2023-02-22T12:00:00+01:00",
"values": 6124
},
{
"date": "2023-02-22T13:00:00+01:00",
"values": 5135
},
{
"date": "2023-02-22T14:00:00+01:00",
"values": 3412
},
{
"date": "2023-02-22T15:00:00+01:00",
"values": 1816
},
{
"date": "2023-02-22T16:00:00+01:00",
"values": 721
},
{
"date": "2023-02-22T17:00:00+01:00",
"values": 189
},
{
"date": "2023-02-22T17:33:00+01:00",
"values": 0
}
]
}
}