This is my script to save the output into a csv file:
import os, csv, datefinder, datetime
os.chdir('C:\Users\dul\Desktop\Article')
with open("test2.txt", 'r') as file1:
text1 = file1.read()
matches = list(datefinder.find_dates(text1))
if len(matches) > 0:
date = matches[1]
print date
else:
print 'No dates found'
csv = open(date, "w")
columnTitleRow = "date, time\n"
csv.write(columnTitleRow)
When I run this script, I get this error message:
[Traceback (most recent call last): File "C:\Users\dul\Desktop\Article\ap.py", line 18, in csv = open(date, "w") TypeError: coercing to Unicode: need string or buffer, datetime.datetime found]