1
1
import glob
2
2
3
3
import pandas as pd
4
- import pandas . DataFrame as df
4
+ from pandas import DataFrame
5
5
6
6
from Class .Match import Match
7
7
from Class .Port import Port
@@ -12,7 +12,7 @@ def __init__(self, matchList: [Match] = [Match], outPortList: [Port] = [Port], i
12
12
self .matchList = matchList
13
13
self .portListDict = {str : [Port ]}
14
14
self .portDict = {str : Port }
15
- self .dfDict = {str : df } # in,out,match
15
+ self .dfDict = {str : DataFrame () } # in,out,match
16
16
17
17
def learn_folder (self , path2folder = '..\excel\learn/220-母线&线路-第一套合并单元&第一套合并单元' ):
18
18
for filename in glob .iglob (path2folder + '**/*.xls' , recursive = True ):
@@ -29,9 +29,6 @@ def learn_excel(self, path2excel):
29
29
inPort = Port (row [1 ]['开入端子描述' ], row [1 ]['开入端子引用' ])
30
30
match = Match (outPort , inPort )
31
31
self .matchList .append (match )
32
- df = self .dfDict .get ('开出' , df )
33
- key = row [1 ]['开出端子描述' ] + row [1 ]['开出端子引用' ]
34
- port = df .get (key )
35
32
except RuntimeError :
36
33
print (row [1 ])
37
34
print (dir (self .matchList ))
@@ -46,21 +43,24 @@ def load_excel(self, path2excel='..\excel\learn/220-母线&线路-第一套合
46
43
portList .append (port )
47
44
key2 = row [1 ][title + '端子描述' ] + title + row [1 ][title + '端子引用' ]
48
45
self .portDict [key2 ] = port
49
- df = self .dfDict .get (title , df )
46
+ df = self .dfDict .get (title , DataFrame ())
47
+ df2 = DataFrame ()
50
48
if sheetName == '已配置' :
51
49
df [key2 ] = df .get (key2 , {object : float })
52
50
else : # new
53
- for done in df :
54
- done [key2 ] = done .get (key2 , float ) # is autoFill metaData useful?
51
+ if key2 not in df .index :
52
+ df2 .reindex ([key2 ])
53
+ print (df2 .index [key2 ])
54
+
55
+
55
56
self .portListDict [key ] = portList
56
57
except RuntimeError :
57
58
print (row [1 ])
58
- print (dir (portList ))
59
59
60
60
61
- def load_test (self , path2excel = '..\excel\learn/220-母线&线路-第一套合并单元&第一套合并单元/赤厝.xls' ):
62
- self .load_excel (path2excel , sheetName = '所有发送' , title = '开出' )
63
- self .load_excel (path2excel , sheetName = '所有接收' , title = '开入' )
61
+ def load_test (self , path2excel = '..\excel\learn/220-母线&线路-第一套合并单元&第一套合并单元/赤厝.xls' ):
62
+ self .load_excel (path2excel , sheetName = '所有发送' , title = '开出' )
63
+ self .load_excel (path2excel , sheetName = '所有接收' , title = '开入' )
64
64
65
65
66
66
def transform (multilevelDict ):
0 commit comments