CSV column - Total value

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Mark Prior Mark Prior 3 weeks, 1 day ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #53891
    Profile photo of Mark Prior
    Mark Prior
    Participant

    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

    #53905
    Profile photo of Dan Potter
    Dan Potter
    Participant

    A little code golf for you.

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

    #53959
    Profile photo of Mark Prior
    Mark Prior
    Participant

    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

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.