Last active
August 29, 2015 14:16
-
-
Save lgwapnitsky/31deaf16727762151bae to your computer and use it in GitHub Desktop.
Breaking down CSV file information by date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$files = dir *.csv | where {$_.length -gt 0} | |
$z = foreach ($file in $files) { | |
write-progress -id 1 -activity $file.name -status "processing..." | |
$x = import-csv $file | |
$y = new-object -type psobject -Property @{ | |
Project = $file.basename | |
Total = $x.count | |
Nov2014 = ($x | where {($_.date -ne $null) -and ([datetime]$_.date -gt [datetime]::parse("11-1-2014")) -and ([datetime]$_.date -lt [datetime]::parse("12-1-2014"))}).count | |
Dec2014 = ($x | where {($_.date -ne $null) -and ([datetime]$_.date -gt [datetime]::parse("12-1-2014")) -and ([datetime]$_.date -lt [datetime]::parse("1-1-2015"))}).count | |
Jan2015 = ($x | where {($_.date -ne $null) -and ([datetime]$_.date -gt [datetime]::parse("1-1-2015")) -and ([datetime]$_.date -lt [datetime]::parse("2-1-2015"))}).count | |
Feb2015 = ($x | where {($_.date -ne $null) -and ([datetime]$_.date -gt [datetime]::parse("2-1-2015")) -and ([datetime]$_.date -lt [datetime]::parse("3-1-2015"))}).count | |
} | |
$y | |
} | |
$z | select Project,Total,Nov2014,Dec2014,Jan2015,Feb2015 | export-csv -NoTypeInformation TFS_Nov2014-Feb2015Activity.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment