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' 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 -- https://mail.python.org/mailman/listinfo/python-list