1

I'm outputting a column in excel using XLRD - with it outputting like below:

for row in range(sheet.nrows):
    sheet.cell_value(row,0)


'user1'
'user2'
'user3'

However, I would like it in the form:

['user1', 'user2', 'user3']
Scoots
  • 3,048
  • 2
  • 21
  • 33
Luka Hans
  • 11
  • 1
  • Possible duplicate of [What does "list comprehension" mean? How does it work and how can I use it?](https://stackoverflow.com/questions/34835951/what-does-list-comprehension-mean-how-does-it-work-and-how-can-i-use-it) – mkrieger1 Dec 12 '17 at 17:57

1 Answers1

0

Use a list comprehension:

cell_values = [ sheet.cell_value(row,0) for row in range(sheet.nrows) ]

Result:

['user1', 'user2', 'user3']
dijksterhuis
  • 1,225
  • 11
  • 25