Skip to main content

Helper

To work with data downloaded from optiCLOUD, we offer a lot of tips, tricks and tools in this section to make your life easier. In time, some of the functions will be available natively in optiCLOUD, but there are so many different preferences that we will probably not be able to map everything in optiCLOUD.

Here you will find some scripts to help you work with the data.

Powershell

For those who use Windows, Powershell is usually usable if appropriate user rights are granted. In most systems, however, the execution of scripts is blocked by default. To temporarily remove this restriction, you can execute the following command:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process

which in most cases removes the restriction to execute scripts for the current shell.

Notifications Export

When exporting notifications, you will receive a .zip file with all alarms in individual .JSON files. The reason for this is that we do not want to tell you how you want to process the notifications. Following this idea, you will receive the "raw data"

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 &plus;= $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)