Splitting data into multiple arrays

I have data as below where two instance values are being stored but are separated by semicolon in the same field. Is there a way these values can be split into 2 arrays? 

 

Original data:

bravo_equipment_port: "11;2" bravo_equpment_label: "1;22" bravo_equipment_ru: "1;2" bravo_cabinet_number: "08-134 - 8kW -X;06-207 - 17kW -C" bravo_port_id: "1;2" bravo_switch_label: "1;2" bravo_connection_id: "11;2" alpha_equipment_port: "1;2" alpha_equipment_label: "1;2" alpha_equipment_ru: "1;2" alpha_cabinet_number: "08-011;07- 86kW -C" alpha_port_id: "1;2" alpha_switch_label: "1;2" alpha_connection_id: "1;22"

 

The result should be like..example of one array:  {11,1,1,08-134 - 8kW -X,1,1,11,1,1,1,08-011,1,1,1}

 

TIA :)

  Discussion posts and replies are publicly visible

  • Hi - assuming your data is in variant format and that each value is a pair of items then something like this for the first array:

    load(
    local!myData: {
    bravo_equipment_port: {11;2},
    bravo_equpment_label: {1;22},
    bravo_equipment_ru: {1;2},
    bravo_cabinet_number: {"08-134 - 8kW -X";"06-207 - 17kW -C"},
    bravo_port_id: {1;2},
    bravo_switch_label: {1;2},
    bravo_connection_id: {11;2},
    alpha_equipment_port: {1;2},
    alpha_equipment_label: {1;2},
    alpha_equipment_ru: {1;2},
    alpha_cabinet_number: {"08-011";"07- 86kW -C"},
    alpha_port_id: {1;2},
    alpha_switch_label: {1;2},
    alpha_connection_id: {1;22}
    },
    local!result1:
    fn!append(
    local!myData.bravo_equipment_port[1],
    local!myData.bravo_equpment_label[1],
    local!myData.bravo_equipment_ru[1]
    /* etc */
    ),
    local!result1
    )

    It may be that the size of each value array is in itself variable, in which case you'd need to embed the above in a loop.
  • Hi Stewart,
    Thanks for the above reply.
    Although the mentioned method works, it gives an incorrect value for the text in "bravo_cabinet_number" when append is used
    It gives it as "-81348"
  • This is because an array is 'typed' . The first value we add is an integer, so the array is typed as "List of Number (Integer)" and when we come to add the string value Appian is casting it to Integer:

    fn!cast(
    typeof(1),
    "08-134 - 8kW -X"
    )

    gives a result of -81348

    If you want your array to contain a mix of types you'll have to generate the output as a Dictionary; or you can cast all of the output as Text:

    fn!append(
    local!result1,
    fn!tostring(local!myData.bravo_equipment_port[1]),
    fn!tostring(local!myData.bravo_equpment_label[1]),
    fn!tostring(local!myData.bravo_equipment_ru[1]),
    fn!tostring(local!myData.bravo_cabinet_number[1])
    /* etc */
    )
  • 0
    Certified Lead Developer
    To keep the data as you specify, you might want to explicitly type cast everything as text.