Python Forum
Match CSV files for difference
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Match CSV files for difference
#1
Hi guys!

I have a real-life problem and wanted to know if there is a way to do it in more efficient way. I have two CSV files I need to compare to see if there are any differences. Let's say we have a table:

...file1.csv.....file2.csv
.....A..............A
.....B..............C
.....C..............E
.....D..............F
.....E..............G
.....R..............Z
.....Z..............H

My outcome will be: [B,D,F,G,R,H] because those values are either in file1 or in file2 - but not in both of them. The way I tackled this is I iterated through each row in file1 and file2 creating lists from them and got differences using:

diff = set(list1) - set(list2)

The problem is, both files are containing almost 100k records each and it takes an awful lot of time to iterate through them. Is there a better way to work on big sets of data like this? I'm using csv library and Python 3.5.
Reply


Messages In This Thread
Match CSV files for difference - by Cuz - Dec-17-2018, 06:19 PM
RE: Match CSV files for difference - by Cuz - Dec-18-2018, 01:12 PM
RE: Match CSV files for difference - by ichabod801 - Dec-18-2018, 01:25 PM
RE: Match CSV files for difference - by Cuz - Dec-18-2018, 02:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Move Files based on partial Match mohamedsalih12 2 805 Sep-20-2023, 07:38 PM
Last Post: snippsat
  Open and read multiple text files and match words kozaizsvemira 3 6,731 Jul-07-2021, 11:27 AM
Last Post: Larz60+
  python 3 find difference between 2 files pd007 2 2,122 May-22-2020, 01:16 AM
Last Post: Larz60+
  Look for match in two files and print out in the first file Batistuta 0 1,586 Mar-03-2020, 02:27 PM
Last Post: Batistuta
  Difference Between 2 files enigma619 3 2,752 Dec-21-2019, 01:39 PM
Last Post: Gribouillis
  How to match two CSV files timlamont 9 5,583 Oct-01-2019, 05:54 PM
Last Post: timlamont
  Python Script to Produce Difference Between Files and Resolve DNS Query for the Outpu sultan 2 2,489 May-22-2019, 07:20 AM
Last Post: buran
  Compare two large CSV files for a match Python_Newbie9 3 5,781 Apr-22-2019, 08:49 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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