-
Notifications
You must be signed in to change notification settings - Fork 0
/
ac_no_identify.py
40 lines (36 loc) · 1.57 KB
/
ac_no_identify.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
# -*- coding: cp1251 -*-
# Ñêðèïò ïðîâåðêè àêòèâíûõ êàðò íà ïðåäìåò èõ âêëþ÷åíèÿ â r1
import subprocess as sp
import fnmatch
import os
import sys
#1. first buld SET of active cards
ac_file=open('C:\\Share_transport\\autoscript\\ac.csv')
ac_text=ac_file.read()
ac_ls=ac_text.split('\n')
AC=set(ac_ls)
AC.discard('')
#2. buld SET of identifyed cards
lc_root_folder=r"C:\Share_transport\LINK\nko"
tree = os.walk(lc_root_folder) #äåðåâî ïàïîê è ôàéëîâ â îáúåêòå-ãåíåðàòîðå
LC=set()#ñîçäàåì ïóñòîå ììíîæåñòâî
for d in tree:
for f in d[2]:
#print (os.path.join(d[0],f)) #ñïèñîê ôàéëîâ ñ ïîëíûì ïóòåì
if fnmatch.fnmatch(f, 'RegisterPerson_*.csv'): #ôèëüòð ôàéëîâ ïî ìàñêå - r1
cur_file=open(os.path.join(d[0],f)) #îòêðûâàåì îòîáðàíûé ôàéë
cur_file_text = cur_file.read()
cur_file_ls = cur_file_text.split('\n') #ðàçäåëÿåì íà îòäåëüíûå ñòðîêè
for s in cur_file_ls: #öèêë ïî êàæäîé ñòðîêå
cur_str = s.split(';')
if len(cur_str)>1: #îòñåêàåì ïóñòûå ñòðîêè
try:
if len(cur_str[10])==19: #ïðîâåðêà äëèíû ïîëÿ
LC.add(cur_str[10][10:]) #äîáàâëåíèå ýëåìåíòà âî ìíîæåñòâî
except:
print ('Îøèáêà â ôàéëå: ',os.path.join(d[0],f))
logfile = open('log_no_identify.txt','w')
logfile.write( 'Àêòèâíûå êàðòû, êîòîðûõ íåò â ðååñòðàõ èäåíòèôèêàöèè: '+str(len(AC-LC))+'\n')
for n in AC-LC:
logfile.write(n+'\n')
print ('Àêòèâíûå êàðòû, êîòîðûõ íåò â ðååñòðàõ èäåíòèôèêàöèè: '+str(len(AC-LC))+'\n' + ' ïîäðîáíîñòè â log_no_identify.txt')