Powershell :- Get sum of two columns in csv file

Lets find the sum of Debit and Credit columns in csv along with file name

# loop through all the csv files in the folder and get sum of Debit_total and Credit_total

gci “Files\CCD_9335_9336_9338_9339\*.csv” | % {[pscustomobject]@{Debit_total = ((import-csv $_).Debit | measure -Sum).sum;Credit_total = ((import-csv $_).Credit | measure -Sum).sum;csv = $_.name}}

Below is the output

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s