<div dir="ltr"><div><div><div>Hi everyone,<br><br></div>I am using QGIS 1.9 Master in Ubuntu 12.10. I am trying to develop a plugin and need to extract data from attributes tables of the .shp.<br><br></div>I created a GUI for the user can Open shp from the computer and the code recognize the shp file and I can get the name of the .shp, name of columns, etc. but I can not get the values for each row and work with them.<br>
<br>I follow the cookbook but when I type "provider.select(allAttrs)" the python console in QGIS says:<br><br>"AttributeError:QgsVectorDataProvider' object has no attribute 'select' <br><br></div>
here is the code I used: (i didn't copy the definition of GUI because with that is any prolem)<br><div><br><div>from PyQt4 import QtGui, QtCore<br>from PyQt4 import *<br>from qgis.core import *<br>from PyQt4.QtCore import *<br>
from PyQt4.QtGui import *<br><br>import qgis.utils, sys<br># supply path to where is your qgis installed<br>QgsApplication.setPrefixPath("/usr/", True)<br>#load providers<br>QgsApplication.initQgis()<br><br>*******<br>
<br> self.ln_lnk.setText(str(self.filename_lnk))<br> <br> lnk_shp = QgsVectorLayer(self.filename_lnk, 'casires', 'ogr')<br> <br> if not lnk_shp.isValid():<br> print "doesnt work"<br>
QtGui.QMessageBox.Warning(self, "Warning", "shp not valid", QtGui.QMessageBox.Ok)<br> <br> try:<br> provider = lnk_shp.dataProvider()<br> feat = QgsFeature()<br>
allAttrs = provider.attributeIndexes()<br> <br> <br> provider.select(allAttrs)<br> attr_list =[]<br> <br> <br> while provider.nextFeature(feat):<br>
<br> attrs = feat.attributeMap()<br> for(k,attr) in attrs.iteritems():<br> attr_list.append(attr.toString())<br> <br> except:<br>
self.ln_save.setText("Falsch")<br><br><br></div><div>I try the same plugin in a oldest version of QGIS 1.7.5 and it works or at least doesn't show this "Falsch". I am wondering during a week and have no idea to sole this. I would really apreciate if someone can solve this problem because is really important to create this plugin and for tha I need to take the data from the attribute table, if not I can not continuous anymore.<br>
<br>Does anyone what is wrong and why my QGIS doesnt recognize the provider.select(allAttrs)?<br></div><div>I would like to know if somebody knows how to install a oldest version of QGIS (e.g. 1.7.5)??<br><br></div><div>thank you so much!!<br>
</div></div></div>