Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when parsing turtle file #2790

Closed
lymereJ opened this issue May 15, 2024 · 4 comments
Closed

Error when parsing turtle file #2790

lymereJ opened this issue May 15, 2024 · 4 comments

Comments

@lymereJ
Copy link

lymereJ commented May 15, 2024

Using 0.7.0 running the following code gives me the following error. I've tried different version of Python, but I get the same error every time. It does seem to work on other machine so I'm not sure why it fails on mine. Any idea? The turtle file referenced below is here.

import rdflib
g = rdflib.Graph()
g.parse('./resources/brick/Brick.ttl')
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
Cell In[4], [line 1](vscode-notebook-cell:?execution_count=4&line=1)
----> [1](vscode-notebook-cell:?execution_count=4&line=1) g.parse('./resources/brick/Brick.ttl', format="ttl")

File c:\Python310\lib\site-packages\rdflib\graph.py:1492, in Graph.parse(self, source, publicID, format, location, file, data, **args)
   [1489](file:///C:/Python310/lib/site-packages/rdflib/graph.py:1489) parser = plugin.get(format, Parser)()
   [1490](file:///C:/Python310/lib/site-packages/rdflib/graph.py:1490) try:
   [1491](file:///C:/Python310/lib/site-packages/rdflib/graph.py:1491)     # TODO FIXME: Parser.parse should have **kwargs argument.
-> [1492](file:///C:/Python310/lib/site-packages/rdflib/graph.py:1492)     parser.parse(source, self, **args)
   [1493](file:///C:/Python310/lib/site-packages/rdflib/graph.py:1493) except SyntaxError as se:
   [1494](file:///C:/Python310/lib/site-packages/rdflib/graph.py:1494)     if could_not_guess_format:

File c:\Python310\lib\site-packages\rdflib\plugins\parsers\notation3.py:2021, in TurtleParser.parse(self, source, graph, encoding, turtle)
   [2019](file:///C:/Python310/lib/site-packages/rdflib/plugins/parsers/notation3.py:2019) if not stream:
   [2020](file:///C:/Python310/lib/site-packages/rdflib/plugins/parsers/notation3.py:2020)     stream = source.getByteStream()
-> [2021](file:///C:/Python310/lib/site-packages/rdflib/plugins/parsers/notation3.py:2021) p.loadStream(stream)
   [2023](file:///C:/Python310/lib/site-packages/rdflib/plugins/parsers/notation3.py:2023) for prefix, namespace in p._bindings.items():
   [2024](file:///C:/Python310/lib/site-packages/rdflib/plugins/parsers/notation3.py:2024)     graph.bind(prefix, namespace)

File c:\Python310\lib\site-packages\rdflib\plugins\parsers\notation3.py:479, in SinkParser.loadStream(self, stream)
    [478](file:///C:/Python310/lib/site-packages/rdflib/plugins/parsers/notation3.py:478) def loadStream(self, stream: Union[IO[str], IO[bytes]]) -> Optional["Formula"]:
--> [479](file:///C:/Python310/lib/site-packages/rdflib/plugins/parsers/notation3.py:479)     return self.loadBuf(stream.read())

OSError: [Errno 22] Invalid argument
@lu-pl
Copy link

lu-pl commented Jun 24, 2024

You are on a Windows machine and use a unix path.

@lymereJ
Copy link
Author

lymereJ commented Jun 24, 2024

@lu-pl - I get the same outcome if I run:

g.parse(".\\resources\\brick\\Brick.ttl")

@lu-pl
Copy link

lu-pl commented Jun 25, 2024

Sorry I don't know anything about windows. Parsing the file works flawlessly on Linux.

Do you have read permissions for that file? Can you open it with open? You can also try passing a pathlib.Path to Graph.parse.

@lymereJ
Copy link
Author

lymereJ commented Jun 26, 2024

I do, but I think your suggestion is on the right track. I found that the file is backed-up by Microsoft's OneDrive, and when OneDrive is not running that file is not available. That's when I get the error, the error goes away when OneDrive is running!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants