My excel files contains some specific values and one of the cells contains general description. Sometimes in the description there are some warning messages with certain keywords (e.g. high, low, increase, decrease, closure). Is there a way to search for these specific words in an excel cell (the words might be in a sentence;e.g. unexpected high volume) and get the cell location?
I tried the following code, but not working. (just minor update, instead of knowing the cell location, I want to copy the files which do not have the warning message keywords)
import glob
import os
import shutil
import xlrd
os.chdir("C:/Users/tsengineer/Desktop/New folder/Trial")
choice = raw_input("Specify the Year to Copy (e.g. 2012) and Press Enter ")
location = raw_input("Specify the location to Copy (e.g. C:\Users\tsengineer\Desktop) and Press Enter ")
notcopy = ("increase", "decrease", "high", "low", "Closure")
for file in glob.glob("*.xls"):
if choice in file:
book = xlrd.open_workbook(file)
sheet = book.sheet_by_index(0)
for row in range(sheet.nrows):
for column in range(sheet.ncols):
if notcopy in sheet.cell(row,column).value:
continue
else:
shutil.copy(file, location)
print "Copying Complete:"