[Qgis-developer] QGIS 1.8 shows only last record of a delimited text imported layer
Rafael Varela Pet
rafael.varela at gmail.com
Thu Mar 21 10:20:32 PDT 2013
Hi,
I'm experiencing problems running the following script in QGIS 1.8:
---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---
from qgis.core import *
from PyQt4.QtCore import *
inFileName="/tmp/test.csv"
url = QUrl.fromLocalFile( inFileName )
capaImportada = QgsVectorLayer( QString.fromAscii( url.toEncoded() ),
"testLayer", "delimitedtext" )
pr=capaImportada.dataProvider()
pr.featureCount()
QgsMapLayerRegistry.instance().addMapLayers( [capaImportada] )
---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---
("test.csv" is attached to this message)
In QGIS 1.8, pr.featureCount() shows the correct number of features (7L) but the
feature table always shows only the last record. The layer metadata also
seems correct. Tha same happens both in Windows or Debian.
The script works fine in QGIS master but that means to adapt all the
code of my plugin.
An alternative coud be to use the OGR driver:
capaImportada = QgsVectorLayer( inFileName, "ogrTest", "ogr" )
but I need the ability to ignore an arbitrary number of lines at the
beginning of the file, but I cannot find any way to do it with OGR.
Does anybody know of other workarounds?
Best regards,
--
Rafael Varela
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.csv
Type: text/csv
Size: 101 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20130321/93c6273b/attachment-0001.csv>
More information about the Qgis-developer
mailing list