-2
I made a code for texte Mining, but I’m having difficulty comparing if the date that was identified has already passed + 1 year. I would like a help or a vision that can help in my understanding.
import re
from pprint import pprint
from openpyxl import load_workbook
from openpyxl import Workbook
caminho = './amostra.xlsx
arquivo_excel = load_workbook(caminho)
planilha = arquivo_excel['Plan1']
for row in planilha.values:
# VERIFICA O TIPO (J OU F)
if(type(row[1]) is str ):
tamanho_j = row[52] == 'J' and len(row[83]) <= 250
tamanho_f = row[52] == 'F' and len(row[83]) <= 100
if(tamanho_f or tamanho_j):
# VERIFICAR SE TEM DATA ( aqui no caso está minha dúvida para comparar a data)
result = re.search(r'\d{2}/\d{2}/\d{2}', row[83])
if(result != None):
#VERIFICA AS PALAVRAS CHAVES
if (row[83] in ['Visitado', 'Visitada','Fachada', 'Fachadas', 'Box', 'instalações' ,
'instalação','instalada', 'instalado','estoque', 'funcionários', 'funcionário','layout']):
print(row[83])
else:
print("não há palavras")
else:
print("SEM DATA")
else:
print("ACIMA DOS CARACTERES")
if(type(row[2]) is str):
tamanho_j = len(row[84]) <= 100
tamanho_f = len(row[84]) <= 50
Got it, perfect. Thank you!
– pauloalmansa
Dear @pauloalmansa test first calmly, I just corrected the first code, copy it again and test, so let me know if it’s okay or not.
– Guilherme Nascimento
I took the concept and managed to implement, is that actually the file reads an excel file and it checks if there is a date. If it is longer than 1 year that is registered, it will not pass the test and will return me the error. If it is within 1 year, it passes to the next tests. Thanks for the help.
– pauloalmansa
@pauloalmansa blz, mark the answer as correct please.
– Guilherme Nascimento
@fernandosavio was vestigios of the first response, I did not remove, thanks. I’ve edited.
– Guilherme Nascimento
@fernandosavio was distracted, just now noticed, group(0) already solved everything without need to concatenate, adjusted to simplify
– Guilherme Nascimento