Tuesday, 7 March 2017

python - Pyshp 1.2 example from documentation fails


I must be doing something really stupid because I am trying to run an example straight from the PyShp (shapefile.py) 1.2 documentation with the only change being the input shapefile and it is failing. Note that it is 32bit Python 2.6 on Server 2008 R2 64bit.



The code:


import shapefile
e = shapefile.Editor(shapefile="F:/data/IntermediateWorkspace/5day_pgn.shp")
e.poly(parts=[[[5.1,5],[9.9,5],[9.9,1],[7.5,3],[5.1,1]]])
e.record("Appended","Polygon")
e.save('F:/data/IntermediateWorkspace/5day_pgn')

The error:



Traceback (most recent call last): File "F:\scripts\shapetest.py", line 2, in e = shapefile.Editor(shapefile="F:/data/IntermediateWorkspace/5day_pgn.shp") File "C:\Python26\ArcGIS10.0\lib\shapefile.py", line 1048, in init self.records = r.records() File "C:\Python26\ArcGIS10.0\lib\shapefile.py", line 520, in records self.__dbfHeader() File "C:\Python26\ArcGIS10.0\lib\shapefile.py", line 443, in __dbfHeader fieldDesc = list(unpack("<11sc4xBB14x", dbf.read(32))) error: unpack requires a string argument of length 32




Thanks for any help!!




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...