Home >Backend Development >Python Tutorial >Python tutorial on how to find the intersection of two csv files
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!