-
Notifications
You must be signed in to change notification settings - Fork 0
/
zona221a223.py
78 lines (67 loc) · 2.23 KB
/
zona221a223.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import os
import sys
import fileinput
# os.chdir("/Users/MissOgra/Documents")
if len(sys.argv) == 3:
archivoreemplazo = sys.argv[1]
fname = sys.argv[2]
# archivoreemplazo = 'PSTD20210325cabecera.txt'
# fname = 'clorinda.txt'
# if len(fname) < 1 : fname = "words.txt"
fh= open(fname)
counter = 0
revendmapas=dict()
for listrevend in fh:
revends = listrevend.rstrip().split()
for revend in revends:
revendmapas[revend] = counter
counter += 1
fh.close
for k,v in revendmapas.items():
# print ("Clave:",k,"Valor:",v)
qrevend= k.split(";")
qrevend=qrevend[0]
# print(qrevend)
# for k,v in dicMapas.items():
# print ("Clave:",k,"Valor:",v)
fnameBus = 'qzobuscar.txt'
fbus= open(fnameBus)
counter = 0
dicBus = dict()
for lineB in fbus:
wordsB = lineB.rstrip().split()
for wordB in wordsB:
dicBus[wordB] = counter
counter += 1
fbus.close()
cuentarev=0
cuentareemplazos=0
## Bloque principal del programa
for mirev,z in revendmapas.items():
cuentarev+=1
qrevend= mirev.split(";")
buscorev=qrevend[0]
for k,v in dicBus.items():
# print ("Clave:",k,"Valor:",v)
zonas= k.split(";")
qbusco=zonas[0]
qreemplazo=zonas[1]
for line in fileinput.input(archivoreemplazo,inplace=True, backup ='.bak'):
sec=line[3:6]
zonasec=qbusco+sec
zonasecreemp=qreemplazo+sec
if buscorev in line :
# print ('Encontre la REvendedora!!!!')
if zonasec in line:
# print('Encontre la Zona!')
cuentareemplazos+=1
print(line.replace(zonasec,zonasecreemp),end='')
else:
print(line, end='')
else:
print(line, end='')
# print(qbusco,qreemplazo )
print("Se han procesado : "+str(cuentarev)+" revendedoras.")
print("Se han reemplazado: "+str(cuentareemplazos)+" revendedoras.")
else:
print ("No tiene los parámetrso requeridos")