diff --git a/public/CsvColumList.ps1 b/public/CsvColumList.ps1 new file mode 100644 index 0000000..e303e82 --- /dev/null +++ b/public/CsvColumList.ps1 @@ -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 \ No newline at end of file diff --git a/public/CsvKeyList.ps1 b/public/CsvKeyList.ps1 new file mode 100644 index 0000000..2f98c63 --- /dev/null +++ b/public/CsvKeyList.ps1 @@ -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 \ No newline at end of file