Python Forum

Full Version: How to find sum difference between two csv
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I have two csv files.
Csv 1
A 1
B 2
C 3

Csv 2
A 10
B 20
C 30

How do i find the sum difference of column 2

Like 10-1+20-2+30-3

So output csv would be

A 9
B 18
C 27
Total 54

I can achieve the difference but not total. Any help?
Is this assignment? Are you allowed to use specific libraries?
You can use Pandas to solve the problem. Look at Pandas pandas.read_csv utility function. You can easily load each file into memory and do what you want.
No this is not assignment.

Is there any live example you can also provide?
To be fair, this seems like a pretty trivial problem given the example you've provided. What have you tried? If you're able to work out the difference and have the values for each row, then adding them up should be simple enough.