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
k,stalab
1,Alcazar
2,Algete
3,Almendralejo
4,Almendralejo_2
5,Baneras
6,Cordoba
7,Cordoba_2

_______________________________________________
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to