Mercurial > hg > audio-features-catalogue
comparison fca/writeHTML.py @ 0:62d2c72e4223
initial commit
author | nothing@tehis.net |
---|---|
date | Mon, 25 Feb 2013 14:40:54 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:62d2c72e4223 |
---|---|
1 def writeHTML(path, matrix, columns, rows): | |
2 html = "<table border=1><tr><th></th>" | |
3 | |
4 for it in columns: | |
5 html += "<th>" + it + "</th>" | |
6 | |
7 html += "</tr>" | |
8 | |
9 for i in range(len(rows)): | |
10 html += "<tr><td>" + rows[i] + "</td>" | |
11 for j in range(len(columns)): | |
12 if matrix[i][j] == 1: | |
13 html += "<td>x</td>" | |
14 else: | |
15 html += "<td></td>" | |
16 html += "</tr>" | |
17 | |
18 html += "</table>" | |
19 | |
20 if path != '': | |
21 file = open(path, 'w') | |
22 file.write(html) | |
23 file.close() | |
24 | |
25 return html | |
26 | |
27 | |
28 def writeWikiTable(path, matrix, columns, rows): | |
29 wiki = "{| class='wikitable' \n" | |
30 | |
31 wiki += ("! align='left'| \n") | |
32 | |
33 for it in columns: | |
34 wiki += ("! " + it + "\n") | |
35 | |
36 for i in range(len(rows)): | |
37 wiki += "|-\n" | |
38 wiki += "| align='left'| " + rows[i] + "\n" | |
39 for j in range(len(columns)): | |
40 if matrix[i][j] == 1: | |
41 wiki += "| align='center'| x\n" | |
42 else: | |
43 wiki += "| \n" | |
44 | |
45 wiki += "|}\n" | |
46 | |
47 if path != '': | |
48 file = open(path, 'w') | |
49 file.write(wiki) | |
50 file.close() | |
51 | |
52 return wiki | |
53 | |
54 | |
55 def writeLatexTable(path, matrix, columns, rows): | |
56 latex = "\\begin{center} \n\\begin{tabular}{ | l |" | |
57 | |
58 for it in columns: | |
59 latex += (" l |") | |
60 | |
61 latex += "}\n\hline\n & " | |
62 | |
63 for i in range(len(columns)): | |
64 latex += columns[i] | |
65 if i < len(columns)-1: | |
66 latex += " & " | |
67 | |
68 latex += " \\\ \hline\n" | |
69 | |
70 for i in range(len(rows)): | |
71 latex += rows[i].replace("_", "") + " & " | |
72 for j in range(len(columns)): | |
73 if matrix[i][j] == 1: | |
74 latex += "x" | |
75 else: | |
76 latex += " " | |
77 if j < len(columns)-1: | |
78 latex += " & " | |
79 | |
80 latex += " \\\ \hline\n" | |
81 | |
82 latex += "\end{tabular}\n\end{center}" | |
83 | |
84 if path != '': | |
85 file = open(path, 'w') | |
86 file.write(latex) | |
87 file.close() | |
88 | |
89 return latex | |
90 | |
91 | |
92 def writeCXT( path, matrix, cols, rows ): | |
93 cxt = "B\n\n" + str(len(rows)) + "\n" + str(len(cols)) + "\n\n" | |
94 | |
95 for it in rows: | |
96 cxt += it + "\n" | |
97 | |
98 for it in cols: | |
99 cxt += it + "\n" | |
100 | |
101 for i in range(len(rows)): | |
102 for j in range(len(cols)): | |
103 if matrix[i][j] == 1: | |
104 cxt += "X" | |
105 else: | |
106 cxt += "." | |
107 cxt += "\n" | |
108 | |
109 if path != '': | |
110 file = open(path, 'w') | |
111 file.write(cxt) | |
112 file.close() | |
113 | |
114 return cxt | |
115 | |
116 def writeFIMI( path, matrix, cols, rows ): | |
117 | |
118 fimi = "" | |
119 | |
120 for i in range(len(rows)): | |
121 for j in range(len(cols)): | |
122 if matrix[i][j] == 1: | |
123 fimi += str(j)+" " | |
124 fimi += "\n" | |
125 | |
126 if path != '': | |
127 file = open(path, 'w') | |
128 file.write(fimi) | |
129 file.close() | |
130 | |
131 return fimi |