Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions public/CsvColumList.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<#
.SYNOPSIS
Returns a list of column names from a CSV file.

.DESCRIPTION
This function reads a CSV file and returns a list of its column names.

.PARAMETER FilePath
The path to the CSV file.

.EXAMPLE
Get-CsvColumnList -FilePath "C:\path\to\file.csv"

.NOTES
#>
function Get-CsvColumnList {
[CmdletBinding()]
param (
[Parameter(Mandatory)][string]$Path
)

$csv = Import-Csv -Path $Path
$csv | Get-Member -MemberType NoteProperty | Select-Object -ExpandProperty Name
} Export-ModuleMember -Function Get-CsvColumnList
21 changes: 21 additions & 0 deletions public/CsvKeyList.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<#
.SYNOPSIS
Returns a list of key values derived from CSV data.

.DESCRIPTION
This function reads a CSV file and returns a list of unique values from a specified key column.

.EXAMPLE
Get-CsvKeyList -Path "C:\path\to\file.csv" -KeyColumn "Id"
#>
function Get-CsvKeyList {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)][string]$Path,
[Parameter(Mandatory=$true)][string]$KeyColumn
)

$csv = Import-Csv -Path $Path
$csv | Select-Object -ExpandProperty $KeyColumn | Sort-Object -Unique

} Export-ModuleMember -Function Get-CsvKeyList