GeospatialPython / pyshp

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

Writing to only one shapefile type throwing an error #237

Closed mem00 closed 2 years ago

mem00 commented 2 years ago

w = shapefile.Writer(shp="/path/tofile.shp")

as per the documentation

w = shapefile.Writer(dbf='shapefiles/test/onlydbf.dbf') w.field('field1', 'C')

throws

ShapefileException: No file-like object available.

when trying to write a polygon

w.poly(geometry)

karimbahgat commented 2 years ago

I was able to reproduce your error. We did have unit tests for this usecase that created a writer, but the error only happens when trying to add the first shape which we didn't do in the test. Will get this fixed for the next release, though if you're able to submit a PR that will be faster.

karimbahgat commented 2 years ago

Fixed the error and the tests, should be available in next version. Thanks for finding the issue!