def parse_options_data(table): rows = body.findAll('tr') header = _unpack(rows[0], kind='th') print header data = [_unpack(r) for r in rows[:]] L1=[] for i in data: if len(i)>4: if len(i)==6: L1.append(i[0:-2]) else: L1.append(i[0:-2]) for i in range(0,len(L1)): for ii in range(0,len(L1[i])): oo=L1[i][ii].strip() L1[i][ii]=oo res=TextParser(L1, names=header).get_chunk() res=res.applymap(f) #not if downloading is # res.index=res[0] # res= res.reindex(columns=res.columns[1:]) # res=res.T res.columns=['name','ticker','supprice','reported_eps','estimat'] #------------------------------------ return res
def parse_options_data(table): rows = table.findAll('tr') header = _unpack(rows[0], kind='th') data = [_unpack(r) for r in rows[1:]] L1=[] for i in data: if len(i)>4: L1.append(i) # if len(i)==6: # L1.append(i[1:]) # else: # L1.append(i) for i in range(0,len(L1)): for ii in range(0,len(L1[i])): oo=L1[i][ii].strip() L1[i][ii]=oo res=TextParser(L1, names=header).get_chunk() res=res.applymap(f) #not if downloading is # res.index=res[0] # res= res.reindex(columns=res.columns[1:]) # res=res.T #------------------------------------ return res