Boas pessoal, Preciso de ajuda para comparar dados de colunas csv com outro csv. Para obter o endereço correto.
import csv
import pandas as pd
import numpy as np
from pandas import DataFrame
cp7 = ""
cp4 = ""
local = ""
tv = ""
nr = ""
nll = sum(1 for line in open('example.csv')) # count the number of lines
nl = nll - 1
for row in range(nl):
df1 = pd.read_csv("example.csv", names=['CP7', 'CP4', 'Local', 'TV', 'NR'])
df2 = pd.read_csv("CTT.csv", names=['CP7', 'CP4', 'Local', 'TV', 'NR'])
pn = pd.read_csv("PNorm.csv", names=['CP7', 'CP4', 'Local', 'TV', 'NR'])
if cp7 is True:
# compare column with another csv file
if cp7 == 1: # cp7 matches with only one address
File = open('Norm.csv', 'w')
Norm = csv.writer(File)
Norm = [row for col in Norm]
File.close()
else: # all cp7 possibilities
File = open('PNorm.csv', 'w')
PNorm = csv.writer(File)
PNorm = [row for col in PNorm]
File.close()
elif cp4 is True: # all cp4 possibilities
# compare column with another csv file
File = open('PNorm.csv', 'w')
PNorm = csv.writer(File)
PNorm = [row for col in PNorm]
File.close()
else:
pass
if local is True: # all local possibilities
# read local
File = open('PNorm.csv', 'w')
PNorm = csv.writer(File)
PNorm = [row for col in PNorm]
File.close()
else:
pass
if tv is True:
# compare column with another csv file
if tv == 1: # TipVia matches with only one address
File = open('Norm.csv', 'w')
Norm = csv.writer(File)
Norm = [row for col in Norm]
File.close()
else: # all TipVia possibilities
File = open('PNorm.csv', 'w')
PNorm = csv.writer(File)
PNorm = [row for col in PNorm]
File.close()
else:
pass
if nr is True:
# compare column with another csv file
if nr == 1: # NomeRua_NumPol matches with only one address
File = open('Norm.csv', 'w')
Norm = csv.writer(File)
Norm = [row for col in Norm]
File.close()
else: # all possibilities
File = open('PNorm.csv', 'w')
PNorm = csv.writer(File)
PNorm = [row for col in PNorm]
File.close()
else:
pass