-2
import csv
positive_vocab = [csv.reader(open('SentiWS_v1.8c/SentiWS_v1.8c_Positive.txt', 'r'), delimiter='|')]
negative_vocab = [csv.reader(open('SentiWS_v1.8c/SentiWS_v1.8c_Negative.txt', 'r'), delimiter='|')]

print(*positive_vocab)

How can I print this list without getting this error:

<_csv.reader object at 0x104be66d8>
Diogo Rocha
  • 9,759
  • 4
  • 48
  • 52
simplesystems
  • 839
  • 2
  • 14
  • 28

1 Answers1

3

You can use list comprehension (if you need to do something with row)

result = [row for row in csv.reader(...)]

or list()

result = list(csv.reader(...))

--

ps. this gives list of lists [ [row1-word1, row1-word2, ...], [row2-word1, ...], ...]

furas
  • 134,197
  • 12
  • 106
  • 148
  • perfect thx, but know some words look like this: NN\t0.0040\ or this 'ADJX\t0.0040\tbahnbrechenden when printing them out – simplesystems Nov 29 '15 at 16:24