I'm stuck with a very simple issue.. I've loaded in QGIS (through the py console) a csv layer (no geometry) made of 4 fields and 3 rows:
#load the csvlayer = QgsVectorLayer("path/to/the/csv", "csvlayer", "delimitedtext")#add it to the TOCQgsMapLayerRegistry.instance().addMapLayer(layer)What I'm trying to do is to store the attribute table of the csv layer in a python list. I tried:
for i in layer.getFeatures(): l = [] l.append(i.attributes())it works, but in the list I have only the last row of the attribute table and not all the 3 rows.
How can I have store all the 3 rows as lists in the main list?
Something like:
l[[1,2,3], [4,5,6], [7,8,9]]Thanks to all!
أكثر...
#load the csvlayer = QgsVectorLayer("path/to/the/csv", "csvlayer", "delimitedtext")#add it to the TOCQgsMapLayerRegistry.instance().addMapLayer(layer)What I'm trying to do is to store the attribute table of the csv layer in a python list. I tried:
for i in layer.getFeatures(): l = [] l.append(i.attributes())it works, but in the list I have only the last row of the attribute table and not all the 3 rows.
How can I have store all the 3 rows as lists in the main list?
Something like:
l[[1,2,3], [4,5,6], [7,8,9]]Thanks to all!
أكثر...