Issue
I am a very beginner on coding. Could you please help me how I can read / print a gml file on Python Anaconda using networkX? I installed the library and code looks like this:
import networkx as nx
g = nx.read_gml("gebaude.gml")
print(nx.info(g))
and after I run it, console looks like this:
runfile('C:/Users/aksupi/Desktop/Experiment1.py', wdir='C:/Users/aksupi/Desktop')
Traceback (most recent call last):
File "C:\Users\aksupi\Desktop\Experiment1.py", line 10, in <module>
g = nx.read_gml("gebaude.gml")
File "<decorator-gen-812>", line 2, in read_gml
File "C:\Users\aksupi\anaconda3\lib\site-packages\networkx\utils\decorators.py", line 213, in _open_file
fobj = _dispatch_dict[ext](path, mode=mode)
FileNotFoundError: [Errno 2] No such file or directory: 'gebaude.gml'
[enter image description here][2]
What is the problem? Where do I need to put the gml file on my computer?
I will be looking forward to hearing from you soon.
Best regards,
Pinar
Solution
You can use the absolute path (the full path) of the file or if you want to use a relative path (in this case the name) you need to set the current working directory accordingly. In this case the working directory is C:/Users/aksupi/Desktop
(you can see it in the wdir
of the runfile
call that Spyder does when running a file) so the file needs to be at C:/Users/aksupi/Desktop/
(so its absolute path will be C:/Users/aksupi/Desktop/gebaude.gml
).
Just in case, inside Spyder the current working directory is shown in the top right:
Answered By - Daniel Althviz
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.