Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #74604
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <jason.swails@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'syntax': 0.04; 'column': 0.07; 'error:': 0.07; 'subject:Error': 0.07; 'variables': 0.07; '[1,': 0.09; 'indicates': 0.09; 'release.': 0.09; 'subject:plot': 0.09; 'url:github': 0.09; 'valueerror:': 0.09; 'cc:addr:python- list': 0.11; 'python': 0.11; 'bug': 0.12; '(these': 0.16; '**kwargs)': 0.16; 'assigns': 0.16; 'bug,': 0.16; 'col': 0.16; 'collections': 0.16; 'columns': 0.16; 'handled.': 0.16; 'ioerror:': 0.16; 'list"': 0.16; 'skip:n 50': 0.16; 'subject:random': 0.16; 'tuple': 0.16; 'unpack': 0.16; 'v),': 0.16; 'valueerror': 0.16; 'exception': 0.16; 'url:)': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'pfxlen:0': 0.19; "skip:' 30": 0.19; 'later': 0.20; 'command': 0.22; 'input': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'error': 0.23; 'looks': 0.24; '(or': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '(see': 0.26; '15,': 0.26; 'certain': 0.27; 'skip:_ 20': 0.27; 'values': 0.27; 'gets': 0.27; 'header:In-Reply- To:1': 0.27; 'fixed': 0.29; 'am,': 0.29; 'then.': 0.30; 'code': 0.31; '"",': 0.31; 'pos': 0.31; 'file': 0.32; 'there.': 0.32; 'probably': 0.32; 'stuff': 0.32; 'run': 0.32; '(most': 0.33; 'problem': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'next': 0.36; "didn't": 0.36; 'charset:us-ascii': 0.36; 'possible': 0.36; 'should': 0.36; 'too': 0.37; 'list': 0.37; 'message-id:@gmail.com': 0.38; 'ends': 0.38; 'jason': 0.38; 'recent': 0.39; 'weight': 0.39; 'mailing': 0.39; 'either': 0.39; 'major': 0.40; 'read': 0.60; 'skip:l 50': 0.60; 'skip:n 30': 0.60; 'hope': 0.61; 'here:': 0.62; 'header:Message-Id:1': 0.63; 'such': 0.63; 'skip:n 10': 0.64; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'latest': 0.67; 'answer.': 0.68; 'jul': 0.74; '2014,': 0.84; 'again?': 0.84; 'confusing': 0.84; 'directory:': 0.84; 'have.': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=NhRYTdo0q/FnVJ+NlykbJPgWi+/M5YqUmmSf+hQU9gI=; b=P1MypX0RyXtOg9HfwtMTOch7044I3kNzfYUL1LOsWObPclAl+bd77xi4IZrtzeLPpg i34plyyjYWX4DmL5vqdMc6EyAt5huHpyBpwImHOfO3W/QesrSiE3dSQwII9bnnk00ovb sRIJYoNSKleIVN4fwsfvgWyKPFyZ5LZW1gF0xUSs1PKoEnq8hZ0stQxzBaaEdw7T4bAQ PlYZsxRWeRiPqLVD28CwgsyUNBWFggnHX+61ulk1y6xY5ANE5iJO7Qrj/NFyrvoVO496 RHqUvq9OZUpBV7ma2M/b3iTGZg43KUJ/V+XfLcA89yhLAlOLapVT0mQYfdFTUt1lRxkk c+wA== |
| X-Received | by 10.70.140.172 with SMTP id rh12mr19389253pdb.45.1405567480286; Wed, 16 Jul 2014 20:24:40 -0700 (PDT) |
| Content-Type | text/plain; charset=us-ascii |
| Mime-Version | 1.0 (Mac OS X Mail 7.3 \(1878.6\)) |
| Subject | Re: networkx plot random graph Error |
| From | Jason Swails <jason.swails@gmail.com> |
| In-Reply-To | <0d48b8fc-0ed0-434f-8004-5e0ff3693171@googlegroups.com> |
| Date | Wed, 16 Jul 2014 20:24:37 -0700 |
| Content-Transfer-Encoding | quoted-printable |
| References | <0d48b8fc-0ed0-434f-8004-5e0ff3693171@googlegroups.com> |
| To | u2107 <phani.lav@gmail.com> |
| X-Mailer | Apple Mail (2.1878.6) |
| Cc | python-list@python.org |
| 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.11908.1405567488.18130.python-list@python.org> (permalink) |
| Lines | 99 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1405567488 news.xs4all.nl 2879 [2001:888:2000:d::a6]:35964 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:74604 |
Show key headers only | View raw
On Jul 15, 2014, at 3:11 AM, u2107 <phani.lav@gmail.com> wrote:
> I am trying to read a file with 3 columns with col 1 and 2 as nodes/edges and column 3 as weight (value with decimal)
>
> I am trying to execute this code
>
>
> import networkx as nx
>
>
> G = nx.read_edgelist('file.txt', data=[("weight")])
> G.edges(data=True)
>
> edge_labels = dict(((u, v), d["weight"]) for u, v, d in G.edges(data=True))
> pos = nx.random_layout(G)
> nx.draw(G, pos)
> nx.draw_networkx_edge_labels(G, pos, edge_labels=edge_labels)
>
> import matplotlib.pyplot as plt; plt.show()
>
>
>
> Error:
>
> File "graph_one.py", line 4, in <module>
> G = nx.read_edgelist('File.txt', data=[("weight")])
> File "<string>", line 2, in read_edgelist
> File "/usr/local/lib/python2.7/dist-packages/networkx-1.7-py2.7.egg/networkx/utils/decorators.py", line 241, in _open_file
> fobj = _dispatch_dict[ext](path, mode=mode)
> IOError: [Errno 2] No such file or directory: 'contactUSC_nodes_diff_small.txt'
This looks like some file didn't exist which probably should have. The next line looks like you may have fixed the problem and then run the command again? Is this part of the error message? Including stuff like this is confusing (to me, at least).
> lavanya@peerformance:~/Desktop/INRIA_Papers/Python$ python graph_one.py
> Traceback (most recent call last):
> File "graph_one.py", line 4, in <module>
> G = nx.read_edgelist('contactUSC_node_diff_small.txt', data=[("weight")])
> File "<string>", line 2, in read_edgelist
> File "/usr/local/lib/python2.7/dist-packages/networkx-1.7-py2.7.egg/networkx/utils/decorators.py", line 263, in _open_file
> result = func(*new_args, **kwargs)
> File "/usr/local/lib/python2.7/dist-packages/networkx-1.7-py2.7.egg/networkx/readwrite/edgelist.py", line 367, in read_edgelist
> data=data)
> File "/usr/local/lib/python2.7/dist-packages/networkx-1.7-py2.7.egg/networkx/readwrite/edgelist.py", line 286, in parse_edgelist
> for (edge_key,edge_type),edge_value in zip(data,d):
>
> ValueError: too many values to unpack
Collections in python can be "unpacked" using a specific syntax that assigns a tuple of individual variables (or names) to a collection (these can be nested). If there are too many or too few single names, a ValueError gets thrown. Consider:
py> col = [1, 2, 3]
py> a, b, c = col
py> print("{0} {1} {2}".format(a, b, c))
1 2 3
py> a, b = col
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: too many values to unpack
py> a, b, c, d = col
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: need more than 3 values to unpack
The traceback for this exception ends inside the networkx code and either indicates a bug in the networkx code or an input error that is not gracefully handled.
My suggestions are twofold:
1) Upgrade to the latest release. If this is a bug, it's very possible that it was fixed in later releases (1.7 is over 2 years old and there have been a couple major releases since then.
2) Sign up for the networkx mailing list and ask your question there. You are certain to get a faster and more relevant answer. (See the "mailing list" link here: http://networkx.github.io/)
Hope this helps,
Jason
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
networkx plot random graph Error u2107 <phani.lav@gmail.com> - 2014-07-15 03:11 -0700 Re: networkx plot random graph Error Jason Swails <jason.swails@gmail.com> - 2014-07-16 20:24 -0700
csiph-web