def read_symbol(filepath):
with open(filepath, 'rb') as f:
dtype = [('symbol', 'S12'), #OK
('desc', 'S64'), # 12:76 OK
('alt', 'S12'), # 76:88 OK
('base', 'S12'), # 88:100 OK
('group', 'i4'), # 100:104 OK
('digits', 'i4'), # 104:108
('trademode', 'i4'), # 108:112
('bcolor', 'i4'), # 112:116 OK
('id', 'i4'), # 116:120
('u1', 'a1508'), # 120:1628 OK
('u2', 'u4'), # 1628:1632
('u3', 'a8'), # 1632:1640
('u4', 'f8'), # 1640:1648
('u5', 'a12'), # 1648:1660
('spread', 'i4'), # 1660:1664
('u6', 'a16'), # 1664:1680
('swLong', 'f8'), # 1680:1688
('swShort', 'f8'), # 1688:1696
('swap3', 'u4'), # 1696:1700
('u8', 'i4'), # 1700:1704
('conSize', 'f8'), # 1704:1712
('u9', 'a16'), # 1712:1728
('stopLevel', 'u4'), # 1728:1732
('u10', 'a12'), # 1732:1744
('marginInit', 'f8'),# 1744:1752
('marginMant', 'f8'), # 1752:1760
('marginHedg', 'f8'), # 1760:1768
('marginDiv', 'f8'), # 1768:1776
('pointPerUnit', 'f8'), # 1776:1784
('u11', 'a24'), # 1784:1808
('marginCurr', 'S12'), # 1808:1820
('u12', 'S104'), # 1820:1924
('u13', 'i4'), # 1924:1928
('u14', 'f8')] # 1928:1936
df = pd.DataFrame(np.frombuffer(f.read(), dtype=dtype).astype(dtype))
dropnames=[]
for x in range(1,15):
dropnames.append('u'+str(x))
del dropnames[6:7]
dropnames.append("desc")
dropnames.append("alt")
dropnames.append("marginCurr")
df=df.drop(dropnames, axis=1)
return df