Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to match two CSV files
#2
read your files with pandas and then compare df1 and df2

pandas.DataFrame.equals

import pandas as pd

csv1 = "/path/to/csv1.csv"
csv2 = "/path/to/csv2.csv"

f1 = open(csv1, 'r')
with f1:
    df1 = pd.read_csv(f1, delimiter = ',', header=None)

f2 = open(csv2, 'r')
with f2:
    df2 = pd.read_csv(f2, delimiter = ',', header=None)

or use

from pandas.testing import assert_frame_equal
c = assert_frame_equal(df1, df2, check_dtype=False)
print(c)
Reply


Messages In This Thread
How to match two CSV files - by timlamont - Sep-29-2019, 08:25 AM
RE: How to match two CSV files - by Axel_Erfurt - Sep-29-2019, 09:24 AM
RE: How to match two CSV files - by timlamont - Sep-29-2019, 09:53 AM
RE: How to match two CSV files - by perfringo - Sep-29-2019, 10:21 AM
RE: How to match two CSV files - by timlamont - Sep-29-2019, 10:39 AM
RE: How to match two CSV files - by perfringo - Sep-30-2019, 05:02 AM
RE: How to match two CSV files - by buran - Sep-30-2019, 05:46 AM
RE: How to match two CSV files - by DeaD_EyE - Sep-30-2019, 07:16 AM
RE: How to match two CSV files - by DeaD_EyE - Oct-01-2019, 05:11 PM
RE: How to match two CSV files - by timlamont - Oct-01-2019, 05:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Move Files based on partial Match mohamedsalih12 2 855 Sep-20-2023, 07:38 PM
Last Post: snippsat
  Open and read multiple text files and match words kozaizsvemira 3 6,791 Jul-07-2021, 11:27 AM
Last Post: Larz60+
  Look for match in two files and print out in the first file Batistuta 0 1,608 Mar-03-2020, 02:27 PM
Last Post: Batistuta
  Compare two large CSV files for a match Python_Newbie9 3 5,836 Apr-22-2019, 08:49 PM
Last Post: ichabod801
  Match CSV files for difference Cuz 4 3,569 Dec-18-2018, 02:16 PM
Last Post: Cuz

Forum Jump:

User Panel Messages

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