Author Posts

September 8, 2016 at 1:53 pm

Hi All

so, not rally sure where to start with this... so please forgive the lack of any script

in short i have around 100 csv's in one location, all of them have the same headers. The only column i am interested in is column L "ItemCount".

in a perfect world i would like to total all cells in column L, create a new CSV with the file name of each CSV in one column then the result of the sum in another

Quick link to how excel file looks – http://s33.photobucket.com/user/markpriorgtst/media/Capture_3.jpg.html

As i say ideally i would like a file to look like

Column A Column B
APM01.csv 131
APM03.csv 131
ARD01.csv 1035
ARD03.csv 1035

hoping someone can point me in the right direction, thanks

September 8, 2016 at 2:53 pm

A little code golf for you.

gci *.csv | % {[pscustomobject]@{total = ((import-csv $_).numbers | measure -Sum).sum;csv = $_.name}}

September 9, 2016 at 8:44 am

Hi Dan

Legend !

gci "\\eurxmbs01\c$\tmpPFStats\*.csv" | % {[pscustomobject]@{total = ((import-csv $_).itemcount | measure -Sum).sum;csv = $_.name}}  

thanks

1518 A-SPT01.csv
1518 A-SPT03.csv
102852 APM01.csv
51426 APM03.csv
162 ARD01.csv
162 ARD03.csv

June 7, 2017 at 6:59 pm

I found this article and it helped me...Question – how can I add the Totals together?
So I have 10 CSV's – It is actually calculating a SUM of 1 Column in each CSV – It is outputting the correct figure and CSV File but I want a total of all Totals at the end?

June 7, 2017 at 6:59 pm

I found this article and it helped me...Question – how can I add the Totals together?
So I have 10 CSV's – It is actually calculating a SUM of 1 Column in each CSV – It is outputting the correct figure and CSV File but I want a total of all Totals at the end?