Solved

Powershell aggregation of varying CSV Files to one CSV

Posted on 2010-08-17
3
964 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article will show, step by step, how to integrate R code into a R Sweave document
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now