compareTool.py

import csv
import logging
from DataCleaning.library.functions.changeDirectory import *
from floatFormatter import *
from DataCleaning.library.functions.addPath import *

addPath("config")
from config import *

def compareTool():
fname1 = "proof.csv"
fname2 = outputFileName
ind1 = [0, 1, 2]
ind2 = [0, 1, 2]


# read file proof.csv
development2Proof()
f = open(fname1, 'r', encoding='UTF-8')
csvreader = csv.reader(f)
file1 = list(csvreader)
f.close()
proof2Development()

# read .txt file
development2Processed()
with open(fname2, "r", encoding='utf-8') as f:
file2 = f.readlines()
processed2Development()

# create two empty sets
set1 = set()
set2 = set()

# file 1
for i in range(len(file1)):
tempList = file1[i]
tempList0 = []
for j in ind1:
tempElement = tempList[j]
tempList0.append(tempElement)
tempText = "|".join(tempList0)
set1.add(tempText)

# file 2
for i in range(len(file2)):
tempList = file2[i].strip(" ").split("|")
tempList0 = []
for j in ind2:
tempElement = tempList[j]
tempList0.append(tempElement)
tempText = "|".join(tempList0)
set2.add(tempText)
return set1, set2  
原文地址:https://www.cnblogs.com/zhulimin/p/15369449.html