it is me again the Powershell-Newbie (i am working with powershell for 11 days by now).
So what is the problem i have so far: I am reading out csv files from different folders and merge the data into one big csv (bigCSV). The bigCSV is a living document, so i am adding data manually into this worksheet.
The problem is, if I have to update the bigCSV (with new csv files) the existing bigCSV gets overwritten and my manually added data gets lost.
I have tried to add -append to my code, but the result is not satisfying, because the manually added data still consits but now i have duplicates ...
This is my Code so far ...
$Userpath_Access = "$PSScriptRoot"
$txtFiles = Get-ChildItem -Path $Userpath_Access\txt-Import-Datenbank\ -Filter *.csv -Recurse -ErrorAction SilentlyContinue -Force
$csv = foreach ($file in $txtFiles) {
Import-Csv -Path $file.FullName -Delimiter ";" |
Select-Object 'Type (BAY)', 'Order Number (BAY)', 'PCP Number (PCP)', @{label='Project ID (Mosaic)';expression={$($_.'Project')}}, 'Priority (BAY)', @{label='Compound No (Mosaic)';expression={$($_.'Compound No')}},
@{label='Customer (Mosaic)';expression={$($_.'Requestor')}}, @{label='Date Order Created (Mosaic)';expression={$($_.'Order Date')}}, @{label='Comment (Mosaic)';expression={$($_.'Comment')}}, 'Status', 'Data Finalized', @{label='Compound Amount [mg] (Mosaic)';expression={$($_.'Amount')}},
'Mail Address', 'Duration', @{label='Name Of Customer (Mosaic)';expression={$($_.'Requestor')}}, @{label='Vial (Mosaic)';expression={$($_.'Vial')}}, @{label='Mosaic File (Mosaic)';expression={$($_.'Filename')}}, @{label='Date Received (Mosaic)';expression={$($_.'Data import')}},
@{label='Order ID (Mosaic)';expression={$($_.'Order ID')}}
}
$fileOut = Join-Path -Path $Userpath_Access -ChildPath ('Inh_Auftragsliste.csv')
$csv | Export-Csv -Path $fileOut -Delimiter ";" -NoTypeInformation -Append
Now I am searching for a solution, to just add the "new files" to my existing bigCSV.