Is it possible to update an attribute field in a shapefile using pyshp ?
I went through their documentation and all they show is how to create new attribute rather than editing or updating an already existing one.
If updating is not possible, is there any other recommended Python library for doing the same ?
Best Answer
It is the same thing with pyshp, except that you cannot update directly the dbf file. When you read a shapefile, the data are stored in Python lists
but this changes the value in the list or in the dictionary, not in the dbf file. To do this, rather than affecting the original shapefile, it is better to create a copy with the new attribute list (same as Add a Field to an Existing Shapefile or Subsetting a Shapefile by Attributes ).
You can also use other Python libraries like ogr or Fiona (see Using the API of QSpatiaLite plugin for the principles, the data are stored as Python dictionaries)