Replacing last characters after last comma with a string

前端 未结 4 969
庸人自扰
庸人自扰 2021-01-27 23:24

I have a huge text file which look like this:

36,53,90478,0.58699759849,0.33616,4.83449759849,0.0695335954050315,3
36,53,90478,0.58699759849,0.33616,4.8344975984         


        
4条回答
  •  迷失自我
    2021-01-27 23:34

    Here's a PowerShell answer in case you like PS.

    Get-Content C:\Path\To\File.csv | 
        Where{$_ -match '^(.*,)([^,]*)$'} | 
        ForEach { "{0}MI-{1}" -f $Matches[1], $Matches[2].Padleft(2,'0') } |
        Set-Content C:\Path\To\NewFile.csv
    

提交回复
热议问题