Solved

Powershell aggregation of varying CSV Files to one CSV

Posted on 2010-08-17
3
971 Views
Last Modified: 2012-05-10
Hi,
I have a daily CSV File that is created but it content changes daily, it is basicly a mail count result.
I want to aggregate the CSV's that are created daily into one file weekly.

file on Sunday would look like this:

Alias, Count
Kevin,1
Jim,2
Roki,1

The file on monday would be :
Alias, Count
Roger,1
Jim, 4
Ralph,1

the weekly aggregated file would have need to look like this (note Jim with 6 mails as an aggregated count):
Alias, Count
Jim, 6
Kevin,1
Ralph,1
Roger,1
roki,1

I know how to aggregate  CSV's but how'd it be done powershell with files that change...
Thanks!
0
Comment
Question by:Elad-It
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
soostibi earned 500 total points
ID: 33452891
I would do this, assuming the files are agg1.txt, agg2.txt, etc. You can adjust the get-item part according to the actual filenames and path:
Get-Item c:\ee\agg*.txt | Import-Csv | Group-Object -Property alias | 
	Select-Object name,  @{n="sum"; e={($_.group | Measure-Object -Property count -Sum).sum}}

Open in new window

0
 

Author Comment

by:Elad-It
ID: 33453001
That works... its simple suddnly when its just writen like that :)
Thanks!!
0
 

Author Closing Comment

by:Elad-It
ID: 33453004
Thanks!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
This article will help you understand what HashTables are and how to use them in PowerShell.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question