<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Simple just:</div><div><br></div><div>For feature in layer.getFeatures():</div><div> For attr in feature:</div><div> Print attr</div><div><br></div><div>If you have field names</div><div><br></div><div>For feature in layer.getFeatures():</div><div> Print feature["field name"]</div><div><br>On 23 Oct 2013, at 7:21 pm, Geo DrinX <<a href="mailto:geodrinx@gmail.com">geodrinx@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div><div><div>OK, I found it !<br><br><br> iter = layer.getFeatures()<br>
for feat in iter:<br> fff = feat.fields()<br> num = fff.count()<br> for iii in range(num):<br> print "%s " %(feat[iii])<br>
<br><br></div>But... what about to have the field names ?<br><br></div>Thank you<br><br></div>Roberto<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/10/23 Geo DrinX <span dir="ltr"><<a href="mailto:geodrinx@gmail.com" target="_blank">geodrinx@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div>Hello all,<br><br></div>I have difficulties writing the python code to print the field value contents from a feature.<br>
<br></div>This is my source code:<br><br> iter = layer.getFeatures()<br>
for feat in iter:<br> fff = feat.fields()<br> num = fff.count()<br> print "num %d\n" %(num)<br> for iii in range(num):<br>
fieldValue = fff[iii]<br> print "%s\n" %(fieldValue)<br><br></div>but this is what I had:<br><br><qgis.core.QgsField object at 0x000000000BF95268><br><br></div>
etcetera....<br><br><br></div>What I need to modify in the source code to have the correct string values ?<br><br></div>Sorry, but the 2.0 documentation is not so clear... actually :(<br><br><br></div><div>Thank you in advance for any info about this<br>
</div><div><br></div>Roberto <br></div>
</blockquote></div><br></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>Qgis-developer mailing list</span><br><span><a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a></span><br><span><a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a></span></div></blockquote></body></html>