MCPcopy Create free account
hub / github.com/OpenBMB/BMTools / convert

Function convert

bmtools/tools/meta_analysis/api.py:214–254  ·  view source on GitHub ↗
(table0)

Source from the content-addressed store, hash-verified

212 return item, tag
213
214def convert(table0):
215 dic = {}
216 table = []
217 for tab in table0:
218 if tab.find('|')==-1:
219 if len(tab.split(':'))==2:
220 tab = '| '+tab.split(':')[0]+' | '+tab.split(':')[1]+' |'
221 else:
222 continue
223 if tab.strip(' ')[0]!='|':
224 tab = '|'+tab
225 if tab.strip(' ')[-1]!='|':
226 tab = tab+'|'
227 table.append(tab)
228 if len(table)<2:
229 return dic
230 segs = table[0].strip('\n').strip(' ')[1:-1].split('|')
231 if len(segs)<2:
232 return dic
233 tag = 1
234 for seg in segs:
235 wd,tmptag = deep_reduce(seg)
236 if tmptag==0:
237 tag = 0
238 break
239 if tag and len(table)>2:
240 vals = table[2].strip('\n').strip(' ')[1:-1].split('|')
241 if len(vals)!=len(segs):
242 return {}
243 for idx in range(len(segs)):
244 wd,tmptag = deep_reduce(segs[idx])
245 dic[wd] = vals[idx]
246 return dic
247 for line in table:
248 wds = line.strip('\n').strip(' ')[1:-1].split('|')
249 if len(wds)!=2:
250 continue
251 wd,tmptag = deep_reduce(wds[0])
252 if tmptag:
253 dic[wd] = wds[1]
254 return dic
255
256def combine(tables, tables1=None, crit=None):
257 extra_query = []

Callers 2

get_tableFunction · 0.70
final_tableFunction · 0.70

Calls 1

deep_reduceFunction · 0.85

Tested by

no test coverage detected