Help with List Variable

  • Renuka__

    Hall of Fame

    Points: 3656


    Please could anyone help me with following requirement. I have output like below -

    ID Name
    1 {a,b,c}
    2 {c,d,e}
    3 {a,e}
    4 {b,d,f}
    5 {a,d,f,g}

    Is it possible to manipulate it to output like

    ID Name
    1 a
    1 b
    1 c
    2 c
    2 d
    2 e
    3 a
    3 e
    4 b
    4 d
    4 f
    5 a
    5 d
    5 f
    5 g

    Any input is greatly appreciated.



  • Sue_H

    SSC Guru

    Points: 90260

    No idea what you are working with so how you do it is impossible to say. However, you can use substring in Powershell. The following returns just the letter a:
    $Name = '{a,b,c}'

    Maybe play around with that to see if you can get the desired output. 


  • frederico_fonseca


    Points: 14173

    it is possible. but you haven't given enough details to give you a working solution.

    assuming you have a list of pairs as per your input you would do a foreach loop
    foreach ($item in $items)
      $splits = $item("Name").replace("{","").replace("}","").split(",")
      foreach ($split in $splits)
       $record = $split|select {N="ID", e=$item{"ID")}, $_.Name
    there are syntax errors above - but the logic could be like it

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply