Me again... I wanted to see if they could help me with a little problem in Python. I have a script that is responsible for analyzing text files. I need to get Python to analyze the last text file that is created in a directory. Is there any way to make the script run by changing the value of a variable, by the name of the last created file? I attach the script to make it easier to understand. Thank you What you have to change the name, is the text file that is in line 2
import re
with open("SPAM Nuevo Lead.txt ","r") as f:
for l in f:
nombre = re.search(r"Nombre:(.*)", l)
if nombre:
valor_nombre = nombre.group(1)
#print(valor_nombre)
telefono = re.search(r"Telefono:(.*)", l)
if telefono:
valor_telefono = telefono.group(1)
#print(valor_telefono)
email = re.search(r"Email:(.*)", l)
if email:
valor_email = email.group(1)
#print(valor_email)