-
Notifications
You must be signed in to change notification settings - Fork 0
/
writeHtmlTable.py
52 lines (34 loc) · 897 Bytes
/
writeHtmlTable.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# -*- coding: utf-8 -*-
"""
Created on Wed June 25 2014
@author: jsmith
"""
import xml.etree.ElementTree as ET
import csv
def readCSV(spreadsheet):
name = str(spreadsheet)
table = {}
table['label'] = []
table['var'] = []
table['description'] = []
stanza1 = '''
<li><a href="{0}">{1}</a></li>
'''
stanza2 = '''
<div id="{0}">{1}</div>
'''
dictReader = csv.DictReader(open(vals, 'rb'), fieldnames=['label', 'var','description'], delimiter=',', quotechar='"')
writeDict(dr=dictReader,d=table)
writeStanzas(d=table,s=stanza,n=name)
def writeDict(dr,d):
for i in dr:
for j in i:
d[j].append(i[j])
return d
def writeStanzas(d,s,n):
f = open("vars.xml","w")
for i in range(0,len(d['name'])-1):
print i,s.format(d['name'][i],d['type'][i],n)
f.write(str(s.format(d['name'][i],d['type'][i],n) + '\n'))
f.close()
readCSV(raw_input("Select a layout file: "))