Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #81521 > unrolled thread
| Started by | Dave Angel <davea@davea.name> |
|---|---|
| First post | 2014-11-25 13:07 -0500 |
| Last post | 2014-11-25 13:07 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Dictionary error Dave Angel <davea@davea.name> - 2014-11-25 13:07 -0500
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2014-11-25 13:07 -0500 |
| Subject | Re: Dictionary error |
| Message-ID | <mailman.16290.1416938881.18130.python-list@python.org> |
On 11/25/2014 04:34 AM, Thuruv V wrote:
> 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
>
>
>
Your email program mangled the code. Please use text mode when posting
here.
It's also generally useful to include the full traceback instead of just
a portion of the error message. And tell us the Python version in case
it matters.
As others have pointed out, zip expects two iterables. My guess is that
you intended the mydict= assignment to be AFTER the while loop has
ended, and that you intended to use x and y, rather than the
poorly-named keys and values.
And if that's the case, you could simplify the code a great deal by just
adding things to the dict in the first place instead of building two
lists first.
--
DaveA
Back to top | Article view | comp.lang.python
csiph-web