In my python application I needed to export some values as csv. But the problem is that I need to "prepend" some values to it. I tried the following solution:
import csv
from datetime import datetime
from collections import deque
def writeCSV(path,participants,values):
time=datetime.now()
with open(path, 'a', newline='') as csvfile:
writer = csv.writer(csvfile)
for value in values:
if type(value) is list:
value.prepend(participants)
value.prepend(time)
writer.writerow(value)
else:
writer.writerow([time,participants,value])
if __name__ == '__main__':
writeCSV('demo.csv',15,[['hentai','ecchi'],['power','ranger']])
But I get the follwing error:
Traceback (most recent call last):
File "csv_deque.py", line 21, in <module>
writeCSV('demo.csv',15,[['hentai','ecchi'],['power','ranger']])
File "csv_deque.py", line 13, in writeCSV
value.prepend(participants)
How I can fix that.