I’m exporting data from python with the csv library which works pretty good. After a web-search I can not find any information about how to format the exported data with python.
For example. I export a csv row within python like this.
for hour_record in object_list:
row = list()
for field in fields:
try:
row.append(getattr(hour_record, field))
except:
pass
writer.writerow(row)
Now I’m wondering how I can pass some formating information to the row.append call. For example if I want to format the text red and make sure that it is formated as a number etc..
anybody an idea how this works?
CSV is used only for plain text. If you want formatting information to be contained then you must either embed HTML fragments, or you must add the attributes as separate fields. Either option will require a consumer that understands said formatting mechanism.