I have a list of values that I would like to add (automatically) as individual headers in my csv file.
I cant seem to get the logic correct - this is what i have thus far:
unique_fields = ['buffcount', 'size', 'ctype', 'atype', 'idiameter', 'row', 'pstatus', 'perminal']
with open(r"C:\Temp\test2\new.csv", 'wb') as outfile:
f = csv.writer(outfile, delimiter=',', quotechar='"')
f.writerow(["FDomain", "CValue", "Descr", unique_fields])
This is what I want the headers to look like:
FDomain | CValue | Descr | buffcount | size | ctype | atype | idiameter | row | pstatus | perminal
What's the best way to add these list items as individual headers?
I've tried list comprehension ( fl for fl in unique_fields ) at the f.writerow function but I get a <generator object <genexpr> error