Hello everyone,
 
I am having a bit of trouble here with my code, which uses a shapefile library, 
named pyshp, to import, edit, and save GIS files within Python.
So, I open up my shapefile (data is polylines, meaning, not points or polygons)
"shapefile=shapefile.Reader("file.shp")
shps=shapefile.shapes()
shprec = shapefile.records()
"
Then I carry out some edits, and I save my file.
When I want to open it again, within the same script, in order to access some 
of the data I just modified, I get this message :
 
"Traceback (most recent call last):
  File "<pyshell#9>", line 1, in <module>
    troncop=troncon.shapes()
  File "C:\Python25\Lib\shapefile.py", line 310, in shapes
    while shp.tell() < self.shpLength:
  File "C:\Python25\Lib\shapefile.py", line 222, in __shape
    print(f.read(8))
  File "C:\Python25\lib\struct.py", line 87, in unpack
    return o.unpack(s)
error: unpack requires a string argument of length 8"
 
 
I reckon this part tries to import header information for shape data, which 
would be stored in C (?), and fails to "unpack" it in PYTHON.
 
I've tried putting an "IF" to check whether f.read(8) was actually a string 
(type) and of length equal to 8. I still get the same error message.
I've also tried skipping the "unpack" part altogther, not with much success.
 
I'm really not too familiar with Python, si if anyone could help me out with 
this, I'd be really grateful.
 
Thanks in advance,
 
S.T.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to