Skip to content

Commit 2427c61

Browse files
authored
Retrieve 1st line only from input file
Retrieves the 1st line only to avoid passing the file object across the pipeline.
1 parent 2fc7ccf commit 2427c61

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Validate-CSVHeaders.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function Validate-CSVHeaders ($correctHeaders) {
88
[ValidateSet('Yes','No')]$validateHeaders = Read-Host "Validate headers?"
99
if ($validateHeaders -eq 'Yes') {
1010
# put all the headers into a comma separated array
11-
$headers = (Get-Content $fileName | Select-Object -First 1).Split(",")
11+
$headers = (Get-Content $fileName -TotalCount 1).Split(",")
1212
for ($i = 0; $i -lt $headers.Count; $i++) {
1313

1414
# trim any leading white space and compare the headers
@@ -21,4 +21,4 @@ function Validate-CSVHeaders ($correctHeaders) {
2121
}
2222
}
2323

24-
Validate-CSVHeaders $correctHeaders
24+
Validate-CSVHeaders $correctHeaders

0 commit comments

Comments
 (0)