Skip to content

Instantly share code, notes, and snippets.

@gitfvb
Last active November 14, 2017 09:25
Show Gist options
  • Save gitfvb/3be2c26756c3a1a3609a96291dd9c77b to your computer and use it in GitHub Desktop.
Save gitfvb/3be2c26756c3a1a3609a96291dd9c77b to your computer and use it in GitHub Desktop.
powershell csv gists
Import-CSV SomeFile.csv | Select *,LINENUMBER | ForEach-Object -Begin { $Line = 1 } {
$_.LineNumber = $Line++
$_
} | Export-CSV SomeFile.csv
# for column "FI_NR",
Import-CSV test.csv -Delimiter ";" | Select *,INCREMENTAL_SUM | ForEach-Object -Begin { $Increment = 0 } {
$Increment += $_.FI_NR
$_.INCREMENTAL_SUM = $Increment
$_
} | Export-CSV SomeFile.csv
# file will be sorted for column username
Import-Csv C:\fso\testusers.csv.old | sort username -Descending | Export-Csv -Path c:\fso\testusers.csv -NoTypeInformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment