Files
ThingsBoard/Code Snippets/filterMistawayPerCustomerDevices.ipynb
2024-10-04 18:53:54 -05:00

75 lines
1.6 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"\n",
"device = {}\n",
"with open(\"/Users/nico/Documents/GitHub/Mistaway API/deviceMaps/deviceMap2024-08-29.json\", \"r\") as f:\n",
" devices = json.load(f)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\n",
"customer_devices = {}\n",
"for key, value in devices.items():\n",
" if value[\"customer\"] == \"CrownQuest\":\n",
" value[\"customer\"] = \"OxyRock\"\n",
" customer_devices[key] = value\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"customer_devices = {}\n",
"for key, value in devices.items():\n",
" customer_devices[key[:-6]] = value[\"deviceName\"]"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"\n",
"with open(\"/Users/nico/Documents/GitHub/Mistaway API/deviceMaps/deviceMap2024-08-29-device.json\", \"w+\") as f:\n",
" json.dump(customer_devices, f, indent=4)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "aws",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
}