GeospatialPython / pyshp

This library reads and writes ESRI Shapefiles in pure Python.
MIT License
1.09k stars 259 forks source link

support pathlib.Path objects as filepath? #234

Closed raphaelquast closed 2 years ago

raphaelquast commented 2 years ago

Hey, I've just noticed that the reader can't deal with pathlib.Path objects... (standard python3 - pathlib)

I guess it should be an easy fix (a simple str() for any path-like object already does the trick...)

from pathlib import Path
import shapefile
shppath = Path(".... path to the shapefile")

r = shapefile.Reader(shppath)         # this will fail
r.records()

r = shapefile.Reader(str(shppath))    # works as expected
r.records()
karimbahgat commented 2 years ago

Thanks for putting this on the radar. Support for pathlib and other path-like objects will be included in next version, see #233.

raphaelquast commented 2 years ago

awesome! nice to hear :-)