Helper
Um mit Daten, die von optiCLOUD heruntergeladen worden sind, zu arbeiten, bieten wir Ihnen in dieser Sektion eine Menge an Tips, Tricks und Tools an, um ihre Leben einacher zu gestalten. Mit der Zeit werden einige der Funktionen nativ in optiCLOUD zur Verfügung stehen, jedoch bestehen so viele verschiedene Präferenzen, dass wir vermutlich nicht alles in optiCLOUD werden abbildern können.
Hier finden sie einige Skripte, die ihnen helfen mit den Daten zu arbeiten.
Powershell
Für diejenigen, die Windows benutzen, ist Powershell meist nutzbar, wenn entsprechende Nutzerrechte eingeräumt sind. In den meisten Systemen ist jedoch die ausführung von Skripten standardmaaessig blockiert. Um diese Restriktion temporär aufzuheben, können sie folgenen Befehl ausführen:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process
welcher in de meisten Fällen die Restriktion Skripte ausführen zu können für die aktuelle Shell aufhebt.
Notifications Export
Bei dem Export von Notifications, erhalten Sie eine .zip Datei mit allen Alarmen in einzelnen .JSON Dateien. Dies hat den Grund, das wir Ihnen nicht vorgeben wollen, wie sie die Notifiations weiterverarbeiten wollen. Diesem Gedanken folgend, erhalten Sie die "Rohdaten"
Python
import os
import json
# Define the folder path where the JSON files are located
folder_path = 'path/to/your/json/files'
output_file = 'combined.json'
# Initialize a list to hold the JSON content
json_list = []
# Loop through each JSON file in the folder
for filename in os.listdir(folder_path):
if filename.endswith('.json'):
file_path = os.path.join(folder_path, filename)
# Read the content of the JSON file
with open(file_path, 'r', encoding='utf-8') as f:
json_content = json.load(f)
# Add the JSON content to the list
json_list.append(json_content)
# Save the combined JSON to a new file
with open(os.path.join(folder_path, output_file), 'w', encoding='utf-8') as f:
json.dump(json_list, f, indent=4)" %}
Powershell
param (
[string]$folderPath
)
# Check if the folder path argument is provided
if (-not $folderPath) {
Write-Host "Error: The folder path argument is missing."
Write-Host "Usage: .\combine_json.ps1 -folderPath <path_to_json_files>"
exit
}
# Get all JSON files in the folder
$jsonFiles = Get-ChildItem -Path $folderPath -Filter *.json
# Initialize an array to hold the JSON content
$jsonArray = @()
# Loop through each JSON file
foreach ($file in $jsonFiles) {
# Read the content of the JSON file
$jsonContent = Get-Content -Path $file.FullName -Raw | ConvertFrom-Json
# Add the JSON content to the array
$jsonArray += $jsonContent
}
# Convert the array to JSON format
$combinedJson = $jsonArray | ConvertTo-Json -Depth 10
# Define the output file path
$outputFilePath = "$folderPath\combined.json"
# Save the combined JSON to a new file
$combinedJson | Set-Content -Path $outputFilePath
Write-Host "Combined JSON file has been created at: $outputFilePath"
import os
import json
# Define the folder path where the JSON files are located
folder_path = "path/to/your/json/files"
output_file = "combined.json"
# Initialize a list to hold the JSON content
json_list = []
# Loop through each JSON file in the folder
for filename in os.listdir(folder_path):
if filename.endswith(".json"):
file_path = os.path.join(folder_path, filename)
# Read the content of the JSON file
with open(file_path, "r", encoding="utf-8") as f:
json_content = json.load(f)
# Add the JSON content to the list
json_list.append(json_content)
# Save the combined JSON to a new file
with open(os.path.join(folder_path, output_file), 'w', encoding='utf-8') as f:
json.dump(json_list, f, indent=4)