- 论坛徽章:
- 0
|
- $f ='a:\pscode\TEMP_2018\temp144\bbb.txt'
- $f2 = Get-Content -ReadCount 0 $f
- $hash = @{}
- foreach ($t1 in $f2)
- {
- if ($t1[4] -eq '0')
- {
- $键 = $t1[0..4] -join ''
- }
-
- if ($t1[4] -in $('1','2','3','4','5'))
- {
- $键 = '' + ($t1[0..3] -join '') + '5'
- }
-
- if ($t1[4] -in $('6','7','8','9'))
- {
- $键temp1 = '' + ($t1[0..3] -join '') + '0'
- $键temp2 = [datetime]$键temp1 + [timespan]'00:10:00'
- $键 = $键temp2.tostring('HH:mm')
- }
- $值 = $null
- $null = [system.UInt32]::TryParse($t1.Split()[1],[ref]$值)
- if ( $hash.contains($键) )
- {
- $hash[$键] = $hash[$键] + $值
- }
- else
- {
- $null = $hash.add($键,$值)
- }
- }
- $hash
复制代码
用法:把代码第一行的输入文件,改成你的文件。 |
|