[Qgis-developer] How to get the field values in PyQGis 2 ?
Geo DrinX
geodrinx at gmail.com
Wed Oct 23 02:21:37 PDT 2013
OK, I found it !
iter = layer.getFeatures()
for feat in iter:
fff = feat.fields()
num = fff.count()
for iii in range(num):
print "%s " %(feat[iii])
But... what about to have the field names ?
Thank you
Roberto
2013/10/23 Geo DrinX <geodrinx at gmail.com>
> Hello all,
>
> I have difficulties writing the python code to print the field value
> contents from a feature.
>
> This is my source code:
>
> iter = layer.getFeatures()
> for feat in iter:
> fff = feat.fields()
> num = fff.count()
> print "num %d\n" %(num)
> for iii in range(num):
> fieldValue = fff[iii]
> print "%s\n" %(fieldValue)
>
> but this is what I had:
>
> <qgis.core.QgsField object at 0x000000000BF95268>
>
> etcetera....
>
>
> What I need to modify in the source code to have the correct string values
> ?
>
> Sorry, but the 2.0 documentation is not so clear... actually :(
>
>
> Thank you in advance for any info about this
>
> Roberto
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20131023/69af5bcc/attachment.html>
More information about the Qgis-developer
mailing list