Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #81520
| From | John Gordon <gordon@panix.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Dictionary error |
| Date | 2014-11-25 16:36 +0000 |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <m52b5l$koh$1@reader1.panix.com> (permalink) |
| References | <mailman.16275.1416914234.18130.python-list@python.org> |
In <mailman.16275.1416914234.18130.python-list@python.org> Thuruv V <wasp52dex@gmail.com> writes:
> Please Clarify the 'TypeError: zip argument #1 must support iteration'
> import openpyxl
> book = openpyxl.load_workbook('c:/users/c_thv/desktop/tax.xlsx')
> sheet = book.get_sheet_by_name('Thilip')
> cell = sheet.cell(row=2,column = 4)
> i = 2
> x = []
> y = []while i < 10:
> keys = sheet.cell(row=i,column = 4)
> values = sheet.cell(row = i,column = 5)
> x.append(keys.value)
> y.append(values.value)
> i +=1
> mydict = dict(zip(keys,values)print mydict
The purpose of zip() is to accept two (or more) sequences and return a
single sequence with the corresponding members of the input sequences
paired together.
For example, if you had a list of names and a list of ages, calling zip
on the two lists would produce single list of (name, age) pairs.
But you're calling zip on two single items, not sequences, and you
can't do that.
Glancing over the code it appears that you're saving the cell contents
in two lists, x and y. Perhaps you meant to call zip on those lists
instead of on keys and values?
--
John Gordon Imagine what it must be like for a real medical doctor to
gordon@panix.com watch 'House', or a real serial killer to watch 'Dexter'.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Dictionary error Thuruv V <wasp52dex@gmail.com> - 2014-11-25 15:04 +0530 Re: Dictionary error Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-25 22:30 +1100 Re: Dictionary error John Gordon <gordon@panix.com> - 2014-11-25 16:36 +0000
csiph-web