Reputation: 7752
I am writing like this in Django:
writer.writerow(['VideoName ', 'Director ', 'Cameraman ', 'Editor ', 'Reporter ', 'Tag '])
It is writing in CSV like this:
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = 'attachment; filename="report.csv"'
Video, Director, Cameraman
But I only want:
Video Director Cameraman
I am doing this in Django.
Upvotes: 0
Views: 334
Reputation: 2442
If I understand well, you don't want CSV format in your rows ?
You can writerow "".join(['VideoName ', 'Director ', 'Cameraman ', 'Editor ', 'Reporter ', 'Tag '])
, it will write the VideoName Director Cameraman Editor Reporter Tag
string as a line of you CSV file.
Or you can remove the spaces from your array entries, and specify the space character as CSV separator.
Upvotes: 0
Reputation: 369194
Specify delimiter when create csv.writer.
In addition to that trim field values. ('videoName '
-> 'videoName'
)
>>> import csv
>>> import sys
>>>
>>> writer = csv.writer(sys.stdout, delimiter=' ')
>>> writer.writerow(['VideoName', 'Director', 'Cameraman', 'Editor', 'Reporter', 'Tag'])
VideoName Director Cameraman Editor Reporter Tag
Upvotes: 0
Reputation: 473943
Set a delimiter
when you are initializing your csv.writer
:
writer = csv.writer(buffer, delimiter=" ")
Upvotes: 2