@@ -81,6 +81,38 @@ def create_dataframeINP(inp_path, section='[CONDUITS]', ignore_comments=True,
81
81
return df .rename (index = str )
82
82
83
83
84
+ def create_dataframe_multi_index (inp_path , section = '[CURVES]' , ignore_comments = True ,
85
+ comment_str = ';' , comment_cols = True , headers = None ):
86
+ # find all the headers and their defs (section title with cleaned one-liner column headers)
87
+ headerdefs = funcs .complete_inp_headers (inp_path )
88
+ # create temp file with section isolated from inp file
89
+ tempfilepath = txt .extract_section_from_inp (inp_path , section ,
90
+ headerdefs = headerdefs ,
91
+ ignore_comments = ignore_comments ,
92
+ skipheaders = True )
93
+
94
+ headerlist = HEADERS ['inp_sections' ][section ]
95
+
96
+ with open (tempfilepath , 'r' ) as f :
97
+ data = []
98
+ for line in f .readlines ():
99
+ items = line .strip ().split ()
100
+ if len (items ) == 3 :
101
+ items = [items [0 ], None , items [1 ], items [2 ]]
102
+ if len (items ) == 4 :
103
+ data .append (items )
104
+
105
+ # df = pd.read_csv(tempfilepath, header=None, delim_whitespace=True, skiprows=[0],
106
+ # index_col=[0,1], names=headerlist, comment=comment_str)
107
+
108
+ df = pd .DataFrame (data = data , columns = headerlist )
109
+ df = df .set_index (['Name' , 'Type' ])
110
+
111
+
112
+ # os.startfile(tempfilepath)
113
+ os .remove (tempfilepath )
114
+ return df
115
+
84
116
def get_link_coords (row , nodexys , verticies ):
85
117
"""for use in an df.apply, to get coordinates of a conduit/link """
86
118
0 commit comments