Is there an easy way to strip HTML markup from SQLFORM.grid's CSV/TSV export? I realize I probably need to create a custom export function, but curious if there is an argument or a one liner that would do the trick. Or is there a better way to format the display?
I have the following controller function:
@auth.requires_login()
def index():
response.title = 'Computer Inventory'
db.inventory.id.readable = False
db.inventory.cpu_status.represent = lambda cpu_status, row: \
SPAN(row.cpu_status,
_style='text-transform: uppercase; font-weight: bold; padding:5px; color: %s; background-color: %s' %
('black' if row.cpu_status == 'Staged' else 'white','red' if row.cpu_status == 'Repair' else 'gold'
if row.cpu_status == 'Staged' else 'green' if row.cpu_status == 'In Use' else 'black'))
grid = SQLFORM.grid(db.inventory, csv=True)
return locals()
When I export as CSV/TSV (as displayed to the user) all values for db.inventory.cpu_status are wrapped in SPAN tags for example:
<span style='text-transform: uppercase; font-weight: bold; padding:5px; color: white; background-color: black'>VALUE</span>