Ticket #1737 (closed defect: duplicate)
OGR Shapefile DS requires ds.Destroy() to comit attribute changes (Python)
|Reported by:||crschmidt||Owned by:||hobu|
From within Python, with GDAL 1.4.0, I attempted to use the following code to commit a feature change to disk:
import ogr ds = ogr.Open("TRAINS_ARC.shp", True) l = ds.GetLayer(0) f = l.GetFeature(1) print f.GetFieldAsString(3) f.SetField(3, "Ctps") l.SetFeature(f) l.SyncToDisk()
I placed this in a script (test.py), and ran it as:
When I ran it multiple times, the field output did not change.
If I modified the file to add a "ds.Destroy()" to the end of it, the attribute value was changed.
I believe that I am using the 'standard' old-style Python bindings.
The data I attempted this on is available inside the (self-extracting zipfile) ftp://data.massgis.state.ma.us/pub/shape/state/trains_shp.exe .