I have a log file that is formatted as CSV without headers. The first column is basically a unique identifier for the recorded problems. For the same problem identifier, there may be several lines with different details. I would like to delete rows where the first column is duplicated, because at this time I do not need other data.
At the moment, I have a fairly basic knowledge of PowerShell, so I'm sure that something simple is missing.
Sorry if this is a duplicate, but I could find answers to some parts of the question, but not to the question as a whole.
So far, I am assuming the following:
Import-Csv $outFile | % { Select-Object -Index 1 -Unique } | Out-File $outFile -Append
But this gives me an error:
Import-Csv: Member "LB" is already present. In C: \ Users \ jnurczyk \ Desktop \ Scratch \ POImport \ getPOImport.ps1: 6 char: 1 + Import-Csv $ outFile | % {Select-Object -InputObject $ _ -Index 1 -Unique} | Outside ... + ~~~~~~~~~~~~~~~~~~~~ + CategoryInfo: NotSpecified: (:) [Import-Csv], ExtendedTypeSystemException + FullyQualifiedErrorId: AlreadyPresentPSMemberInfoInternalCollectionAdd, Microsoft.PowerShell.Commands. ImportCsvCommand
source
share