1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
#the actual search function! import pdb import easyexcel import codecs import sys pdb.set_trace() def GetSheets(): FilenameList = [] i = 1 while True: try: worksheet = codecs.open('c:\\blackpytmp\\worksheet' + str(i), 'r', 'utf16') FilenameList.append(worksheet.read()) i = i + 1 except: break return FilenameList def Search(FileStringList, NameList): for filename in FileStringList: for name in NameList: if name in filename: print 'Name ' + name + ' found in ' + filename def MakeUnicode(excelfile): i = 1 while True: try: excelfile.exportsheet(i) i = i + 1 except: break SpreadsheetTested = easyexcel.easyExcel(sys.argv[1]) StringListToSearchFor = file('c:\\blackpytmp\\names.txt').read().decode('utf-16').splitlines() MakeUnicode(SpreadsheetTested) StringListToSearchIn = GetSheets() Search(StringListToSearchIn,StringListToSearchFor) |