Split 2 dimentional array from a _value

Hello everyone,
I have a question about the flux language and how to seperate array data.
For a task I’m creaing a flux script that needs to split a 2 dimentional array. This array is a string in the _value column. For now I have not figured out how I can seperate this string into a list of seperate values.
For the input I have:

table	_result	_measurement	_field	_value	_time	systemid	boardname

0	IoT_notify_latched	value	[["54057df3", 1745424063.0917008, "W106:filter block 5, valve 1, 1.3 mA"], ["07772d3e", 1745424068.3411751, "W106:filter block 5, valve 2, 1.3 mA"], ["c72ec0da", 1745424084.0930417, "W106:filter block 13, valve 1, 1.3 mA"]]	2025-04-28T12:08:58.016Z	d0fe800000153afc	80001d0008146c33

For the output I have put it in excel to show how I would like to split it (seperate records per _value, epochtime, and warningText and setting them as field is also fine but im capable of splitting it when I can receive proper records):

The problem is that I can have multiple start records in a table and need to first map() then, strings.split() and strings.split() it again but i’m struggling with returning proper values. Is there any better way of splitting this? Or does anyone know a solution in the way im trying now?

Thanks!

Hello @Jik,
Does this work for you?

import "array"
import "strings"

data = array.from(rows: [
  {
    _measurement: "IoT_notify_latched",
    _field: "value",
    _value: "[[\"54057df3\", 1745424063.0917008, \"W106:filter block 5, valve 1, 1.3 mA\"], [\"07772d3e\", 1745424068.3411751, \"W106:filter block 5, valve 2, 1.3 mA\"], [\"c72ec0da\", 1745424084.0930417, \"W106:filter block 13, valve 1, 1.3 mA\"]]",
    _time: 2025-04-28T12:08:58.016Z,
    systemid: "d0fe800000153afc",
    boardname: "80001d0008146c33"
  }
])

// Get the raw string from the first record
firstRecord = data |> findRecord(fn: (key) => true, idx: 0)
rawString = strings.trimPrefix(v: strings.trimSuffix(v: firstRecord._value, suffix: "]]"), prefix: "[[")
entries = strings.split(v: rawString, t: "], [")

// Create a list of records, one for each entry
entryList = array.map(
  arr: entries,
  fn: (x) => {
    // Split the entry by comma and clean up the values
    parts = strings.split(v: x, t: ", ")
    id = strings.trimSuffix(v: strings.trimPrefix(v: parts[0], prefix: "\""), suffix: "\"")
    timestamp = float(v: parts[1])
    warningText = strings.trimSuffix(v: strings.trimPrefix(v: parts[2], prefix: "\""), suffix: "\"")
    
    // Return a record with the processed values
    return {
      _time: firstRecord._time,
      systemid: firstRecord.systemid,
      boardname: firstRecord.boardname,
      id: id,
      timestamp: timestamp,
      warningText: warningText
    }
  }
)

// Create the final table from the processed entries
result = array.from(rows: entryList) 
|> yield(name: "test")

Yess this is amazing for splitting the record! Do you also know how I can implement this in a stream of records?
Thank you for the help so far :slight_smile: