1

I am working with a large amount of word files where i would like to make an excel file with where each word file is a column and each word in each document is a row. I am new to python; how would I do this?

I have this code to separate the words:

import string
remove = dict.fromkeys(map(ord, '\n ' + string.punctuation))

with open('data10.txt', 'r') as f:
for line in f:
    for word in line.split():
        w = f.read().translate(remove)
        print(word.lower())

I just need to know how to get each word to be a row in excel.

jgree157
  • 33
  • 5

1 Answers1

0

Easiest way to do this would be to pipe this to a csv file from the command line

python myscript.py > words.csv
maxymoo
  • 35,286
  • 11
  • 92
  • 119
  • When I do that, I'm getting error: Traceback (most recent call last): File "Parse", line 7, in w = f.read().translate(remove) TypeError: expected a character buffer object – jgree157 Feb 29 '16 at 03:24
  • try changing 'r' to 'rb' – maxymoo Feb 29 '16 at 03:26
  • dunno man take a look at http://stackoverflow.com/questions/9786941/typeerror-expected-a-character-buffer-object-while-trying-to-save-integer-to and if that doesnt' help google for "TypeError: expected a character buffer" to see if you can work it out – maxymoo Feb 29 '16 at 03:31