I have got multiple measurement files with one column of numeric data each. (Update: The script should work for variable numbers of measurement files.)
Here's one way:
$files = Get-ChildItem D:\temp *.dat
$header = $files|foreach {$_.basename}
$content= $files | foreach { ,(gc $_.fullname) }
$lines = for($i=0; $i -lt $content[0].Count; $i++)
{
$line = for($x=0; $x -lt $files.count; $x++)
{
$content[$x][$i]
}
$line -join ','
}
$lines | ConvertFrom-Csv -Header $header | Export-Csv data.csv