-
Notifications
You must be signed in to change notification settings - Fork 0
/
getuectp.py
36 lines (35 loc) · 1.85 KB
/
getuectp.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
# -*- coding: cp1251 -*-
# Äëÿ çàìåíû íîâûõ êàðò íà ñòàðóþ
# usage: settle_canhge_new_cards.py file2 file3 file4
# !!!!!!!!!!!!ãäå file1-ôàéë C:\Users\Sizykh\python_example\settle_change_new_cards.pyñ íîìåðàìè êàðò,êîòîðîûå åçäÿò, íî íå ïîïîëíÿëèñü - ïåðåâûïóùåííûå (îäèí íîìåð â ñòðîêå) ÍÅ ÈÑÏÎËÜÇÓÅÒÑß.
# file2 - ôàéë ñ -ñîîòâåòñòâèåì! ïåðåâûïóùåííàÿ êàðòà;ñòàðàÿ êàðòà (îäíà ïàðà â ñòðîêå, ðàçäåëèòåëü ";")
# file3 - ðååñòð ïåðå÷èñëåíèé, â êîòðîì íóæíî ñäåëàòü ïîäìåíó
# file4 - òåêóùèé ðååñòð ïîïîëíåíèé äëÿ ñâåðêè
# C:\Share_transport\LINK\AISVTK\perevipusk\perevip.csv
import subprocess as sp
import fnmatch
import os
import sys
uec_tp_ls=[]
res_file = open('uectp.csv', 'w') #èòîãîâûé ôàéë
lc_root_folder=r"C:\Share_transport\LINK\MINSOC\R1"
tree = os.walk(lc_root_folder) #äåðåâî ïàïîê è ôàéëîâ â îáúåêòå-ãåíåðàòîðå
l = 0
for d in tree:
for f in d[2]:
#if fnmatch.fnmatch(f, 'Ans_r1_*.csv'): #ôèëüòð ôàéëîâ ïî ìàñêå - r1
if fnmatch.fnmatch(f, 'r1_38_*.csv'): #ôèëüòð ôàéëîâ ïî ìàñêå - r1
cur_file=open(os.path.join(d[0],f),'rb') #îòêðûâàåì îòîáðàíûé ôàéë
j = 0
print (f, end='')
#cur_file_ls = [curr_str.decode('cp1251').rstrip() for curr_str in cur_file]
for curr_str in cur_file:
k = 0
j +=1
cur_str_ls = curr_str.decode('cp1251').rstrip().split(';') #öèêë ïî êàæäîé ñòðîêå
for s1 in open(r"C:\Share_transport\UEC\uec_201610.csv"):
s1_ls=s1.rstrip().split(';')
k +=1
print (f+' '+str(0)+' '+str(j)+' '+str(k))
if (cur_str_ls[4]==s1_ls[4]) or (cur_str_ls[0].upper()+cur_str_ls[1].upper()+cur_str_ls[2].upper()+cur_str_ls[3]==s1_ls[0]+s1_ls[1]+s1_ls[2]+s1_ls[3]):
res_file.write(cur_str_ls[5]+';'+cur_str_ls[0]+' '+cur_str_ls[1][0]+cur_str_ls[2][0]+';'+s1_ls[8]+'\n')