Skip to content

possibility to get csv delimiter format with coma or semi-colon #66

@racingtri

Description

@racingtri

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."
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions