Due to a recent change, this is pretty much a continuation of this - Remove leading zeros in the csv file only from int values
I have the following code:
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
After reading the following code:
Import-CSV "C:\path\test.csv" | ForEach-Object{
$_.column 1 = ($_.column 1).TrimStart('0')
$_
} | Export-Csv "C:\path\test2.csv" -NoTypeInformation
Move-Item "C:\path\test2.csv" "C:\path\test.csv" -Force
Now in the csv file has column1been changed to column 1(now there is a space).
I get a syntax compilation error:
Unexpected token 'One' in expression or statement.
At :line:2 char:19
+ $_.Column One <<<< = ($_.Column One).TrimStart('0')
Any help with this would be much appreciated ...
source
share