def matrixToHTML(data,names=None,units=None,bookName=None,sheetName=None,xCol=None):
if not names:<EOL><INDENT>names=["<STR_LIT>"]*len(data[<NUM_LIT:0>])<EOL>if data.dtype.names:<EOL><INDENT>names=list(data.dtype.names)<EOL><DEDENT><DEDENT>if not units:<EOL><INDENT>units=["<STR_LIT>"]*len(data[<NUM_LIT:0>])<EOL>for i in range(len(units)):<EOL><INDENT>if names[i] in UNITS.keys():<EOL><INDENT>units[i]=UNITS[names[i]]<EOL><DEDENT><DEDENT><DEDENT>if '<STR_LIT>' in str(type(data)): <EOL><INDENT>data=data.view(float).reshape(data.shape + (-<NUM_LIT:1>,))<EOL><DEDENT>if xCol and xCol in names:<EOL><INDENT>xCol=names.index(xCol)<EOL>names.insert(<NUM_LIT:0>,names[xCol])<EOL>units.insert(<NUM_LIT:0>,units[xCol])<EOL>data=np.insert(data,<NUM_LIT:0>,data[:,xCol],<NUM_LIT:1>)<EOL><DEDENT>htmlFname = tempfile.gettempdir()+"<STR_LIT>"%(bookName,sheetName)<EOL>html="""<STR_LIT>"""<EOL>html+="<STR_LIT>"<EOL>if bookName or sheetName:<EOL><INDENT>html+='<STR_LIT>'%(bookName,sheetName)<EOL><DEDENT>html+="<STR_LIT>"<EOL>colNames=['<STR_LIT>']<EOL>for i in range(len(units)):<EOL><INDENT>label="<STR_LIT>"%(chr(i+ord('<STR_LIT:A>')),i)<EOL>colNames.append(label)<EOL><DEDENT>html+=htmlListToTR(colNames,'<STR_LIT>','<STR_LIT>')<EOL>html+=htmlListToTR(['<STR_LIT>']+list(names),'<STR_LIT:name>',td1Class='<STR_LIT>')<EOL>html+=htmlListToTR(['<STR_LIT>']+list(units),'<STR_LIT>',td1Class='<STR_LIT>')<EOL>cutOff=False<EOL>for y in range(len(data)):<EOL><INDENT>html+=htmlListToTR([y+<NUM_LIT:1>]+list(data[y]),trClass='<STR_LIT>'%(y%<NUM_LIT:2>),td1Class='<STR_LIT>')<EOL>if y>=<NUM_LIT:200>:<EOL><INDENT>cutOff=True<EOL>break<EOL><DEDENT><DEDENT>html+="<STR_LIT>"<EOL>html=html.replace("<STR_LIT>","<STR_LIT>")<EOL>html=html.replace("<STR_LIT>","<STR_LIT>")<EOL>if cutOff:<EOL><INDENT>html+="<STR_LIT>"%(y,len(data))<EOL><DEDENT>html+="<STR_LIT>"<EOL>with open(htmlFname,'<STR_LIT:w>') as f:<EOL><INDENT>f.write(html)<EOL><DEDENT>webbrowser.open(htmlFname)<EOL>return<EOL>
Put 2d numpy data into a temporary HTML file.