i have a large number of CSV files to merge together with each CSV containing one column. I want each csv file to be a new column in the output file. So far i've got this which works for three files but i can't think of how to scale this up to cycle through a large number of files. Any Ideas?
$csv1 = @(gc "C:\xxx\first.csv")
$csv2 = @(gc "C:\xxx\Second.csv")
$csv3 = @(gc "C:\xxx\Third.csv")
$csv4 = @()
for ($i=0; $i -lt $csv1.Count; $i++) {
$csv4 += $csv1[$i] + ', ' + $csv2[$i] + ', ' + $csv3[$i]
}
$csv4 | Out-File "C:\xxx\merged.csv" -encoding default