I changed the file slightly to make it work as a plugin for 0.11, as seen below.
from trac.wiki.macros import WikiMacroBase
from trac.util import escape
import csv
class CsvMacro(WikiMacroBase):
def get_macros(self):
yield 'CSV'
def get_macro_description(self, name):
return inspect.getdoc(CsvMacro)
def expand_macro(self, formatter, name, txt):
sniffer = csv.Sniffer()
txt = txt.encode('ascii', 'replace')
reader = csv.reader(StringIO(txt), sniffer.sniff(txt))
formatter.out.write('<table class="wiki">\n')
for row in reader:
formatter.out.write('<tr>')
for col in row:
formatter.out.write('<td>%s</td>' % escape(col))
formatter.out.write('</tr>\n')
formatter.out.write('</table>\n')