Попробуйте это:
import xlrd
import os
from string import punctuation, translate
from collections import Counter
filename = u'test.xlsx'
sheet_no = 1 # To get the first sheet of the workbook
path = 'C:\Users\myUsername\Directory for Excel files'
punctuation_map = dict((ord(c), u' ') for c in punctuation)
for filename in os.listdir(path):
if filename.endswith('.xlsx'):
print filename
workbook = xlrd.open_workbook(filename)
sheet = workbook.sheet_by_index(sheet_no)
values = []
for row in range(sheet.nrows):
for col in range(sheet.ncols):
c = sheet.cell(row, col)
if c.ctype == xlrd.XL_CELL_TEXT:
cv = unicode(c.value)
wordlist = cv.translate(punctuation_map).split()
values.extend(wordlist)
numberWords = Counter(wordlist)
print sum(numberWords.values()), ' words for that column'
count = Counter(values)
print sum(count.values()), ' total words counted (from all columns)'