Python Forum
How to find sum difference between two csv
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to find sum difference between two csv
#1
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?
Reply
#2
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.
Reply
#3
No this is not assignment.

Is there any live example you can also provide?
Reply
#4
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to find difference between fake driving license or real using python? pjaymn 2 2,564 Dec-20-2020, 08:41 PM
Last Post: jefsummers
  python 3 find difference between 2 files pd007 2 2,137 May-22-2020, 01:16 AM
Last Post: Larz60+
  python how to find difference between two values hare 1 6,456 Jan-14-2019, 10:18 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020