本帖最后由 ivor 于 2020-12-25 09:51 编辑
保存为utf-8格式- #&cls&@powershell "Invoke-Expression ([Io.File]::ReadAllText('%~0',[Text.Encoding]::UTF8))" &pause&exit
- @(
- (GC "a.txt") | select `
- @{name='col1'; expression={([regex]::Match($_,'^[a-z0-9]+\|\d+')).value}},
- @{name='col2'; expression={([regex]::Match($_,'(?<=\|)[0-9\.]+$')).value}},
- @{name='col3'; expression={([regex]::Match($_,'(\d+)(?=(\|[0-9\.]+$))')).value}}|
- group col1
- ) | %{;$_.Name,('数量:'+ ($_.Group |measure -Property col3 -Sum).Sum),($_.Group | measure -Property col2 -Sum).Sum -join '|'}
复制代码
ax001|1201|数量:80|0.4
ax002|1202|数量:120|0.5
ax003|1203|数量:60|0.1
请按任意键继续. . . |