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

BUG: Unable to open files with fiona where filepath contains a # character #3279

Closed
scazz010 opened this issue May 8, 2024 · 3 comments · Fixed by #3280 or geopandas/pyogrio#412
Closed
Labels

Comments

@scazz010
Copy link

scazz010 commented May 8, 2024

Code Sample, a copy-pastable example

import geopandas as gpd
path = 'file:///dropbox/#02 Datastore/sample.shp'
gpd.io.util._parse_uri(path)

returns

('/dropbox/', '', 'file')

Problem description

Any filepath being opened with fiona via gpd.read_file is parsed through vsi_path() in order to:

# Opening a file via URL or file-like-object above automatically detects a
# zipped file. In order to match that behavior, attempt to add a zip scheme
# if missing.

Which then passes through parseurl which splits on #s and drops part of my file path

Expected Output

(/dropbox/#02 Datastore/sample.shp','', 'file')

Suggested solution idea?

path, archive, scheme = _parse_uri(path)

Could also collect fragments from urlparse and join it to the URI

@m-richards
Copy link
Member

Thanks for the report @scazz010, I can replicate this. Also seems to be an issue writing such files. Hopefully pretty straightforward to resolve.

@JamesParrott
Copy link

I think this is a feature, not a bug.

Octothorps (#s) are reserved characters in URIs, denoting fragments at the end.

https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Example_URIs

@m-richards
Copy link
Member

I think this is a feature, not a bug.

Octothorps (#s) are reserved characters in URIs, denoting fragments at the end.

https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Example_URIs

The issue describe here is to do with reading local file paths containing hashes - these are incorrectly inferred as uri fragments (as geopandas also supports reading from urls/s3/etc directly.

If you have a real world example of where this fix may go wrong with URIs, feel free to share.

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