Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #81521

Re: Dictionary error

Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <davea@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.024
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'subject:error': 0.03; 'argument': 0.05; 'assignment': 0.07; 'skip:o 50': 0.09; 'python': 0.11; 'dict': 0.16; 'expects': 0.16; 'mangled': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'first.': 0.19; 'pointed': 0.19; 'import': 0.22; 'portion': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'generally': 0.29; 'mode': 0.30; 'code': 0.31; 'posting': 0.31; 'keys': 0.31; 'values.': 0.31; 'lists': 0.32; 'text': 0.33; 'guess': 0.33; 'skip:b 30': 0.33; 'skip:d 20': 0.34; 'could': 0.34; 'message.': 0.35; 'case,': 0.35; 'building': 0.35; 'version': 0.36; 'useful': 0.36; 'two': 0.37; 'to:addr:python- list': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'skip:y 20': 0.60; 'tell': 0.60; 'full': 0.61; 'first': 0.61; 'zip': 0.64; 'great': 0.65; 'received:74.208': 0.68; '10:': 0.84; 'received:74.208.4.194': 0.84; 'sheet': 0.93
Date Tue, 25 Nov 2014 13:07:48 -0500
From Dave Angel <davea@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0
MIME-Version 1.0
To python-list@python.org
Subject Re: Dictionary error
References <CAAmLL-J-t5YN+FXYaYWYenMbo9gFRvsy3kDkfkiMMLXxqVwdww@mail.gmail.com>
In-Reply-To <CAAmLL-J-t5YN+FXYaYWYenMbo9gFRvsy3kDkfkiMMLXxqVwdww@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:2+OXkuxJRDN7ShEcVFVwr9iKXHZxXtb/ty42KRjF9Ao jSs9jRsmQf4yLLYNqxujJCF75hgrHMXdsbrbSl0XzVpD4vT4k3 rRXzMyj+r130bCRkfo++lDioPF8X10BwiMr6FhvBc8v57QMxyF fWqMNeA7ffEdUvv+R2p9LChK2VdDwfMA8A1LRbKwpHvplCFv6R NniDiINDoHGwbE6LBRuqMdtdesOdTlr1/07nf/qpTOuFK7aSfq EbVIgx4Z8aAhzVAb7YpO0DZ9tQyHRo3tlsNYMz1jeng3Jgpw85 kn+X74dsJf2nNBxROzQQiLpYcfbglTmKhU2O9139aA/9IXdB/z C3cLmunElHWM8/4LUOtE=
X-UI-Out-Filterresults notjunk:1;
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16290.1416938881.18130.python-list@python.org> (permalink)
Lines 41
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1416938881 news.xs4all.nl 2925 [2001:888:2000:d::a6]:37408
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:81521

Show key headers only | View raw


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 comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Dictionary error Dave Angel <davea@davea.name> - 2014-11-25 13:07 -0500

csiph-web