Table of contents

Merge CSV File with Header File

# Folder relative to run directory that we are checking for a combined CSV # Creates the file if it does not exist and will append to existing $filestowatch= ".\Data Export\employee_badge_numbers.csv" # Check if combined file exists and skip the headers file from running a second time if (!(Test-Path $filestowatch)) { # Files that will be merged in order of top to bottom $files = Get-ChildItem '.\headers.csv', 'export.csv' $files | foreach { Get-Content $_ | Add-Content 'Data Export\employee_badge_numbers.csv' -encoding UNICODE } } else { # Files that will be merged in order of top to bottom $files = Get-ChildItem 'export.csv' $files | foreach { Get-Content $_ | Add-Content 'Data Export\employee_badge_numbers.csv' -encoding UNICODE } }