1

I'm trying to export multidimensional array to csv with some formatting. Currently I'm just doing multidimensional array into object to export out but hoping to get some advice on formatting things.

$dummy = @(("a","b","c"),("1","2","3"),("John","Jane","Smith")

$obj = $dummy | Foreach-Object { [PSCustomObject]@{ 'value' = $_ } }

$obj | Export-CSV -Path "C:\folder\test.csv" -NoTypeInformation

with this code though my results are

enter image description here

hoping to make it look like

enter image description here

or any other way just be more formatted and not set as one cell so to speak

any advice or suggestion would be appreciated

OnesQuared
  • 79
  • 6
  • with the function on [this answer](https://stackoverflow.com/a/73640422/15339544) `$dummy | Join-Array -Columns foo, bar, baz | Export-Csv...` would do what you were expecting I believe – Santiago Squarzon Jun 21 '23 at 19:57
  • 1
    Nitpick - ```$dummy = @(("a","b","c"),("1","2","3"),("John","Jane","Smith")``` is not a [multi-dimensional array](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/arrays/multidimensional-arrays) , it's a [jagged array](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/arrays/jagged-arrays) (or array of arrays). A true multidimensional array would be declared like ```$arr = New-Object "string[,]" 5,5``` and accessed like ```$arr[1, 3] = "aaa"``` and ```$x = $arr[1, 3]```. – mclayton Jun 21 '23 at 21:14

0 Answers0