I want to select those sentences which contains some conjunctions mentioned.But I am getting an error as:
Traceback (most recent call last):
File "positive_process3.py", line 14, in <module>
if word in text:
TypeError: 'str' does not support the buffer interface.
My code is:
import xlrd
from xlrd import open_workbook
import xlwt
wb = open_workbook("C:/Users/SA769740/Desktop/result2/pos.xlsx")
book = xlwt.Workbook(encoding="utf-8")
sheet1 = book.add_sheet("Sheet 1")
wordSet = [' for ', ' so ',' since ', ' Since ', ' because ', ' as ', ' As ', ' due to ', ' Due to ']
count=1
for sheet in wb.sheets():
for row in range(sheet.nrows):
text = ((sheet.cell(row,2).value).encode("utf-8"))
l = ""
for word in wordSet:
if word in text:
l += (word+" ")
sheet1.write(row,0,sheet.cell(row, 0).value)
sheet1.write(row,3, l)
sheet1.write(row,4,count)
sheet1.write(row,5,value)
count += 1
book.save('C:/Users/SA769740/Desktop/result2/pos_reviews_process3.xls')
I am using python 3.4.3