Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to match two CSV files
#1
I'm new to Python from VisualBasic, so excuse my basic question.

I am trying to match two CSV files, based on the data in columns P1-P5:

CSV#1:
Header Row1 = DataCol1, DataCol2, DataCol3, P1, P2, P3, P4, P5
Row2 = data1, data2, data3, 1,2,3,4,5
etc...

CSV#2:
Header Row1 = ColName1, ColName2, ColName3, P1, P2, P3, P4, P5
Row2 = ea1, ea2, ea3, 3,5,6,2,1
Row3 = db1, db2, db3, 1,2,3,4,5
etc...

I would like:

1) To match each row in CSV1 against it's corresponding data in columns P1-P5 in CSV2

2) Combined these matched rows to form a new row in a new file, CSV#3:

eg:-
CSV#3:
Header Row1 = DataCol1, DataCol2, DataCol3, P1, P2, P3, P4, P5, ColName1, ColName2, ColName3, P1, P2, P3, P4, P5
Row1 = data1, data2, data3, 1,2,3,4,5, db1, db2, db3, 1,2,3,4,5
etc...

I am lost how to do this!

Is there a way to do this as quick as possible, bearing in mind the CSV files are large (sometimes up to 99999 rows).

I found a module called "pandas" but it is beyond my current understanding.

Thank you very much :)
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 811 Sep-20-2023, 07:38 PM
Last Post: snippsat
  Open and read multiple text files and match words kozaizsvemira 3 6,738 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,587 Mar-03-2020, 02:27 PM
Last Post: Batistuta
  Compare two large CSV files for a match Python_Newbie9 3 5,793 Apr-22-2019, 08:49 PM
Last Post: ichabod801
  Match CSV files for difference Cuz 4 3,522 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