-
Notifications
You must be signed in to change notification settings - Fork 193
Description
Hello,
On some systems we have default value for regionnal settings based on ";" instead of ",". if the findingfile is open in excel and registered, by default (in france), Excel will transform it in semicolon delimiter.
A workaround could be to add a parameter allowing to personnalize the delimiter option in << Import-Csv -Path $FileFindingList -Delimiter "," >>
It could be possible to add it in the script : an other way could be t check on the firstline the presence of the delimiter and use it afterward ?
Read the first line of the file
$firstLine = Get-Content -Path $csvFilePath -TotalCount 1
Check for common delimiters
if ($firstLine -match ",") {
Write-Output "The delimiter is a comma (,)."
$Delimiter = ","
} elseif ($firstLine -match ";") {
Write-Output "The delimiter is a semicolon (;)."
$Delimiter = ";"
} elseif ($firstLine -match "t") { Write-Output "The delimiter is a tab (
t)."
$Delimiter = "`t"
} else {
Write-Output "The delimiter could not be determined. Please inspect the file manually."
}