Home > Backend Development > Python Tutorial > Python tutorial on how to find the intersection of two csv files

Python tutorial on how to find the intersection of two csv files

巴扎黑
Release: 2017-09-07 09:46:16
Original
2059 people have browsed it

This article mainly introduces the method of finding the intersection of two csv files in Python, involving Python's related operating skills such as reading, traversing, and judging csv files. Friends in need can refer to this article

The example describes how Python implements the intersection of two csv files. Share it with everyone for your reference, the details are as follows:


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

#!/usr/bin/env python

rd3 = open('data_17_17_2.csv')

base = open('data_17_17_3.csv')

wr3 = open('delNoBuyed3DayAndStoreAndInCar4.5.2.csv','w+')

bsData = base.readlines()

i = 1

for key in rd3:

 if key in bsData:

  wr3.write(key)

 if i == 1:

  print key

 i = (i + 1)%100

rd3.close()

base.close()

wr3.close()

Copy after login

The above is the detailed content of Python tutorial on how to find the intersection of two csv files. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template