Home > Net >  Export-CSV Filtering
Export-CSV Filtering

Time:06-01

$Headers = "Username"
Import-CSV -Path "$WorkingFolder\Test.csv" | Select $Headers | Export-CSV -Path "$WorkingFolder\Master.txt" -Force -NoTypeInformation

I am exporting a CSV File as a .txt file and only want to select the data from the Username column. It succesfully outputs as a .txt file and select all the items listed as Usernames. but contains "Information" and the header in the .txt file. I just want the raw data and want to remove the quotation marks and the header. I understand already that I can just skip the first row for exporting if need be but was going to see if there was another way round this.

CodePudding user response:

I guess then what you want is

(Import-Csv -Path "$WorkingFolder\Test.csv").UserName | 
 Set-Content -Path "$WorkingFolder\Master.txt"

P.S. Personally, I would rather use Join-Path -Path $WorkingFolder -ChildPath 'test.csv' to make sure you get the path separator correct

  • Related