JSON to Ignition Dataset

Just having a bit of fun on my computer, I was able to convert your results to a dataset using this script:

# filepath = wherever your file is stored

# Get the file as a string
jsonString = system.file.readFileAsString(filepath)

# Load the file as a json object
jsonFile = system.util.jsonDecode(jsonString)

# Get the first key of the results as a reference for getting the headers and iteration lengths
firstKey = next(iter(jsonFile['results']))

# Get the headers from the first key's keys
headers = jsonFile['results'][firstKey].keys()

# "data =" could be done with comprehension, but nested comprehensions can get convoluted
# Initialize a data list for or the row lists that will comprise the data in the dataset
data = []

# Iterate over the indexes of the first value list in the 'results' dictionary
for index in range(len(next(iter(jsonFile['results'][firstKey].values())))):
	
	# For each key in the 'results' dictionary
	for key in jsonFile['results'].keys():
	
		# Create a row by extracting the 'index'-th element from each value list
		rowData = [value[index] for value in jsonFile['results'][key].values()]
		
		# Append the created row to the 'data' list
		data.append(rowData)
		
# Convert the headers and data into a dataset
dataset = system.dataset.toDataSet(headers, data)

Result:

2 Likes