falta filtrar por fecha y ampliaciones
This commit is contained in:
@@ -3,9 +3,10 @@ from normalizacion import *
|
||||
|
||||
def filtrar_telefono(fichero, tel):
|
||||
f = open(fichero, "r", encoding="utf-8")
|
||||
tel_n = normalizar_telefono(tel)
|
||||
for i in f.readlines():
|
||||
telefono = i.split(";")[0]
|
||||
if telefono.strip() == tel:
|
||||
telefono = normalizar_telefono(i.split(";")[0])
|
||||
if telefono.strip() == tel_n:
|
||||
print(i)
|
||||
else:
|
||||
continue
|
||||
|
||||
@@ -46,23 +46,25 @@ def main():
|
||||
normalizar(fichero, formato_fecha, formato_coordenadas)
|
||||
|
||||
elif '-sphone' in argv:
|
||||
telefono = int(argv[argv.index('-sphone') + 1])
|
||||
telefono = argv[argv.index('-sphone') + 1]
|
||||
fichero = argv[argv.index('-sphone') + 2]
|
||||
filtrar_telefono(telefono, fichero)
|
||||
filtrar_telefono(fichero, telefono)
|
||||
|
||||
elif '-snif' in argv:
|
||||
nif = argv[argv.index('-snif') + 1]
|
||||
fichero = argv[argv.index('-snif') + 2]
|
||||
filtrar_nif(nif, fichero)
|
||||
filtrar_nif(fichero, nif)
|
||||
|
||||
elif '-stime' in argv: # convertir entre formatos
|
||||
desde = argv[argv.index('-stime') + 1]
|
||||
hasta = argv[argv.index('-stime') + 2]
|
||||
fichero = argv[argv.index('-stime') + 3]
|
||||
print("stime")
|
||||
except FileNotFoundError as e:
|
||||
print(e)
|
||||
|
||||
else:
|
||||
exit(1)
|
||||
except:
|
||||
exit(2)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ def normalizar_instante(instante, formato):
|
||||
|
||||
if not d['segundo'].isdigit():
|
||||
d['segundo'] = '00'
|
||||
return f"{d['hora']}:{d['minuto']}:{d['segundo']} {d['dia']}/{d['mes']}/{d['año']}"
|
||||
return f"{d['hora']:0>2}:{d['minuto']}:{d['segundo']} {d['dia']:0>2}/{d['mes']:0>2}/{d['año']}"
|
||||
|
||||
|
||||
def normalizar_telefono(telefono):
|
||||
@@ -44,16 +44,17 @@ def normalizar_coordenada(coordenada, formato):
|
||||
|
||||
def normalizar(fichero, formato_fecha, formato_coordenadas):
|
||||
try:
|
||||
f = open(fichero, 'r')
|
||||
f = open(fichero, 'r', encoding='utf-8')
|
||||
except:
|
||||
exit(1)
|
||||
n = 0
|
||||
for i in f.readlines():
|
||||
telefono, nif, instante, coordenada, producto, precio = i.split(";")
|
||||
instante = normalizar_instante(instante.strip(), 1)
|
||||
instante = normalizar_instante(instante.strip(), formato_fecha)
|
||||
telefono = normalizar_telefono(telefono.strip())
|
||||
coordenada = normalizar_coordenada(coordenada.strip(), 3)
|
||||
print(instante, telefono, coordenada)
|
||||
n_coordenada = normalizar_coordenada(coordenada.strip(), formato_coordenadas)
|
||||
if n_coordenada is None:
|
||||
continue
|
||||
n += 1
|
||||
|
||||
print(n)
|
||||
|
||||
@@ -91,8 +91,8 @@ def gradoDecimal(grados,minutos,segundos):
|
||||
|
||||
|
||||
def validarCoordenada(cadena, form):
|
||||
if P.fullmatch():
|
||||
M = P.fullmatch()
|
||||
if P.fullmatch(cadena):
|
||||
M = P.fullmatch(cadena)
|
||||
if M.group("Grados1"):
|
||||
grados1 = M.group("Grados1")
|
||||
grados2 = M.group("Grados2")
|
||||
@@ -153,7 +153,7 @@ def validarEntrada(entrada):
|
||||
tel = validarTelefono(telefono.strip())
|
||||
dni = validarDni(dni.strip())
|
||||
fecha = validarInstante(fecha.strip())
|
||||
coordenadas = validarCoordenada(coordenadas.strip())
|
||||
coordenadas = validarCoordenada(coordenadas.strip(), 1)
|
||||
|
||||
valores = {
|
||||
'telefono': tel,
|
||||
|
||||
@@ -17,5 +17,5 @@ D = re.compile(d, flags=re.I|re.M)
|
||||
i = r"((?P<anyo>0{3}[1-9]|\d{4})-(?P<mes>0\d|1[0-2])-(?P<dia>[0-2]\d|3[01])\s+(?P<hora>[0-1]\d|2[0-4]):(?P<minuto>[0-5]\d))|((?P<mes>january|february|march|april|may|june|july|august|september|october|november|december)\s+(?P<dia>\d|[12]\d|3[01]),\s+(?P<anyo>0{3}[1-9]|\d{4})\s+(?P<hora>[1-9]|1[0-2]):(?P<minuto>[0-5]\d)\s+(?P<segundo>[ap]m))|((?P<hora>[01]\d|2[0-3]):(?P<minuto>[0-5]\d):(?P<segundo>[0-5]\d)\s+(?P<dia>[0-2]\d|3[01])/(?P<mes>0\d|1[0-2])/(?P<anyo>0{3}[1-9]|\d{4}))"
|
||||
I = re.compile(i, flags=re.IGNORECASE)
|
||||
|
||||
R = r"( *(?P<Grados1>([0-2][0-9][0-9])|(3[0-5][0-9]))(?P<Minutos1>[0-6][0-9])(?P<Segundos1>[0-6][0-9]\.\d{4})(?P<Letra1>(N|S))(?P<Grados2>([0-2][0-9][0-9])|(3[0-5][0-9]))(?P<Minutos2>[0-6][0-9])(?P<Segundos2>[0-6][0-9]\.\d{4})(?P<Letra2>(W|E)) *)|( *(?P<Grados1>((1[0-9][0-9])|(2[0-9][0-9])|(3[0-5][0-9])|\d{2}|\d{1}))° *(?P<Minutos1>([0-5][0-9])|[0-9])' *(?P<Segundos1>(([0-5][0-9])|[0-9])\.\d{4})\" *(?P<Letra1>(N|S)) *, *(?P<Grados2>((1[0-9][0-9])|(2[0-9][0-9])|(3[0-5][0-9])|\d{2}|\d{1}))° *(?P<Minutos2>([0-5][0-9])|[0-9])' *(?P<Segundos2>(([0-5][0-9])|[0-9])\.\d{4})\" *(?P<Letra2>(W|E)) *)|( *((?P<Signo1>[+|\-| ])(?P<Coord1>(([1-8]?[0-9])\.\d+)|90)) *, *((?P<Signo2>[+|\-| ])(?P<Coord2>([1][1-7][1-9]\.\d+)|([1-8]?[0-9]\.\d+))|90) *)"
|
||||
R = r"( *(?P<Grados1>([0-2][0-9][0-9])|(3[0-5][0-9]))(?P<Minutos1>[0-6][0-9])(?P<Segundos1>[0-5][0-9]\.\d{4})(?P<Letra1>(N|S))(?P<Grados2>([0-2][0-9][0-9])|(3[0-5][0-9]))(?P<Minutos2>[0-5][0-9])(?P<Segundos2>[0-5][0-9]\.\d{4})(?P<Letra2>(W|E)) *)|( *(?P<Grados1>((1[0-9][0-9])|(2[0-9][0-9])|(3[0-5][0-9])|\d{2}|\d{1}))° *(?P<Minutos1>([0-5][0-9])|[0-9])' *(?P<Segundos1>(([0-5][0-9])|[0-9])\.\d{4})\" *(?P<Letra1>(N|S)) *, *(?P<Grados2>((1[0-9][0-9])|(2[0-9][0-9])|(3[0-5][0-9])|\d{2}|\d{1}))° *(?P<Minutos2>([0-5][0-9])|[0-9])' *(?P<Segundos2>(([0-5][0-9])|[0-9])\.\d{4})\" *(?P<Letra2>(W|E)) *)|( *((?P<Signo1>[+\- ]?)(?P<Coord1>(([1-8]?[0-9])\.\d+)|90)) *, *((?P<Signo2>[+\- ]?)(?P<Coord2>([1][0-7][0-9]\.\d+)|([1-9]?[0-9]\.\d+))|90) *)"
|
||||
P = re.compile(R)
|
||||
|
||||
Reference in New Issue
Block a user