nothing@0: def writeHTML(path, matrix, columns, rows): nothing@0: html = "" nothing@0: nothing@0: for it in columns: nothing@0: html += "" nothing@0: nothing@0: html += "" nothing@0: nothing@0: for i in range(len(rows)): nothing@0: html += "" nothing@0: for j in range(len(columns)): nothing@0: if matrix[i][j] == 1: nothing@0: html += "" nothing@0: else: nothing@0: html += "" nothing@0: html += "" nothing@0: nothing@0: html += "
" + it + "
" + rows[i] + "x
" nothing@0: nothing@0: if path != '': nothing@0: file = open(path, 'w') nothing@0: file.write(html) nothing@0: file.close() nothing@0: nothing@0: return html nothing@0: nothing@0: nothing@0: def writeWikiTable(path, matrix, columns, rows): nothing@0: wiki = "{| class='wikitable' \n" nothing@0: nothing@0: wiki += ("! align='left'| \n") nothing@0: nothing@0: for it in columns: nothing@0: wiki += ("! " + it + "\n") nothing@0: nothing@0: for i in range(len(rows)): nothing@0: wiki += "|-\n" nothing@0: wiki += "| align='left'| " + rows[i] + "\n" nothing@0: for j in range(len(columns)): nothing@0: if matrix[i][j] == 1: nothing@0: wiki += "| align='center'| x\n" nothing@0: else: nothing@0: wiki += "| \n" nothing@0: nothing@0: wiki += "|}\n" nothing@0: nothing@0: if path != '': nothing@0: file = open(path, 'w') nothing@0: file.write(wiki) nothing@0: file.close() nothing@0: nothing@0: return wiki nothing@0: nothing@0: nothing@0: def writeLatexTable(path, matrix, columns, rows): nothing@0: latex = "\\begin{center} \n\\begin{tabular}{ | l |" nothing@0: nothing@0: for it in columns: nothing@0: latex += (" l |") nothing@0: nothing@0: latex += "}\n\hline\n & " nothing@0: nothing@0: for i in range(len(columns)): nothing@0: latex += columns[i] nothing@0: if i < len(columns)-1: nothing@0: latex += " & " nothing@0: nothing@0: latex += " \\\ \hline\n" nothing@0: nothing@0: for i in range(len(rows)): nothing@0: latex += rows[i].replace("_", "") + " & " nothing@0: for j in range(len(columns)): nothing@0: if matrix[i][j] == 1: nothing@0: latex += "x" nothing@0: else: nothing@0: latex += " " nothing@0: if j < len(columns)-1: nothing@0: latex += " & " nothing@0: nothing@0: latex += " \\\ \hline\n" nothing@0: nothing@0: latex += "\end{tabular}\n\end{center}" nothing@0: nothing@0: if path != '': nothing@0: file = open(path, 'w') nothing@0: file.write(latex) nothing@0: file.close() nothing@0: nothing@0: return latex nothing@0: nothing@0: nothing@0: def writeCXT( path, matrix, cols, rows ): nothing@0: cxt = "B\n\n" + str(len(rows)) + "\n" + str(len(cols)) + "\n\n" nothing@0: nothing@0: for it in rows: nothing@0: cxt += it + "\n" nothing@0: nothing@0: for it in cols: nothing@0: cxt += it + "\n" nothing@0: nothing@0: for i in range(len(rows)): nothing@0: for j in range(len(cols)): nothing@0: if matrix[i][j] == 1: nothing@0: cxt += "X" nothing@0: else: nothing@0: cxt += "." nothing@0: cxt += "\n" nothing@0: nothing@0: if path != '': nothing@0: file = open(path, 'w') nothing@0: file.write(cxt) nothing@0: file.close() nothing@0: nothing@0: return cxt nothing@0: nothing@0: def writeFIMI( path, matrix, cols, rows ): nothing@0: nothing@0: fimi = "" nothing@0: nothing@0: for i in range(len(rows)): nothing@0: for j in range(len(cols)): nothing@0: if matrix[i][j] == 1: nothing@0: fimi += str(j)+" " nothing@0: fimi += "\n" nothing@0: nothing@0: if path != '': nothing@0: file = open(path, 'w') nothing@0: file.write(fimi) nothing@0: file.close() nothing@0: nothing@0: return fimi