0

I need to merge CSV files and want to use following command from post Merging multiple CSV files into one using PowerShell.

Get-ChildItem -Filter *.csv | 
    Select-Object -ExpandProperty FullName |
    Import-Csv |
    Export-Csv .\merged\merged.csv -NoTypeInformation -Append

However, only the first column of the source CSV files ends up in merged.csv.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Axel
  • 1
  • Please provide sample input as well as the desired and actual output for that sample input. [Edit] your question to add this information. – Ansgar Wiechers Jan 16 '19 at 08:59
  • I suspect that the first csv file has only one column or that column is the only common column name among all the csv files. – Sid Jan 16 '19 at 09:02
  • That code will only work if all the csv files have the **same headers** in the **same order**, if it's not working one of these will be the cause. – henrycarteruk Jan 16 '19 at 10:21

1 Answers1

0

Found the issue ...

The tool generating the csv files added as top line sep=,

With this Excel openes the csv already correctly formatted.

After removing this line from the csv files all is working as expected with the Import-csv and Export-csv command.

Best regards, Axel

Axel
  • 1