Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Output two dimensional array to csv file in PowerShell

Given

$a = (("a","b","c"),("d","e","f"))

I want $a exported to a csv file like this

a,b,c
d,e,f

Something so simple seems tricky. What's the best way, my file will be less than 40 lines long.

like image 954
Mark Allison Avatar asked Oct 24 '25 17:10

Mark Allison


1 Answers

Try this

$a | % { $_ -join ','} |  out-file .\myfile.csv
like image 155
CB. Avatar answered Oct 26 '25 08:10

CB.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!