Search code examples
powershellcsvdecimalscientific-notation

Convert Scientific notation to decimal in .csv with Powershell Script


I'm trying to write a Powershell script that converts all scientific notations in a csv file to decimal.

For that :

$list = Import-CSV -Path .\this.csv -Delimiter ";" -Encoding UTF8
foreach($col in $list){
        $col.price = $col.price -as [double]
        Write-Output $col.price
}

But the results of this do not change the output strings.

Any solution ?

Thx. Etienne


Solution

  • I found this :

    foreach($col in $list){
                $col.price = $col.price.Replace(',','.')
                $col.price = $col.price.Replace(' ','') -as [decimal]
                Write-Output $col.price
    }
    

    and it works :D