Remove leading zeros in csv file from int values only

偶尔善良 提交于 2019-12-02 00:24:28

Try using ".TrimStart()" to take out the zeros.

Import-CSV "C:\path\test.csv" | ForEach-Object{
    $_.column1 = ($_.column1).TrimStart('0')
    $_
} | Export-Csv "C:\path\test2.csv" -NoTypeInformation
Move-Item "C:\path\test2.csv" "C:\path\test.csv" -Force

Note that in order for this to work, I had to reformat your first column to take out the extra spaces. Thus, the header in the original csv would start with: column1,column2, and so on.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!