Modify

Opened 19 years ago

Closed 19 years ago

#299 closed enhancement (fixed)

Processor for tab/csv seperated tables to enable cut´n paste from Excel and OpenOffice

Reported by: anonymous Owned by: anybody
Priority: low Component: Request-a-Hack
Severity: minor Keywords:
Cc: mail@… Trac Release: 0.10

Description

Hi,

Cut and paste tables from excel would be simpler than to write two vertical bars before each element.

Example tab seperated values copied from NeoOffice:

123	123	123	123
234	234	234	234

would become

123 123 123 123
234 234 234 234

Attachments (0)

Change History (2)

comment:1 Changed 19 years ago by Alec Thomas

Try this macro out:

from trac.util import escape
from StringIO import StringIO
import csv

def execute(hdf, txt, env):
    sniffer = csv.Sniffer()
    reader = csv.reader(StringIO(txt), dialect=sniffer.sniff(txt))
    out = StringIO()
    out.write('<table class="wiki">\n')
    for row in reader:
        out.write('<tr>')
        for col in row:
            out.write('<td>%s</td>' % escape(col))
        out.write('</tr>\n')
    out.write('</table>\n')
    return out.getvalue()

comment:2 Changed 19 years ago by Alec Thomas

Resolution: fixed
Status: newclosed

Added as CsvMacro.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain anybody.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.