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

巴扎黑
巴扎黑Original
2017-09-07 09:46:162049browse

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:


#!/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()

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!

Statement:
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