Bug report #7493

QGIS 1.8 shows only last record of a delimited text imported layer

Added by Rafael Varela over 11 years ago. Updated over 11 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Python plugins
Affected QGIS version:1.8.0 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed
Crashes QGIS or corrupts data:No Copied to github as #:16444

Description

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<---

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 will require 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 any other workarounds?

test.csv Magnifier (101 Bytes) Rafael Varela, 2013-04-02 12:12 PM

History

#1 Updated by Giovanni Manghi over 11 years ago

  • Status changed from Open to Feedback

did you tested qgis master?

#2 Updated by Rafael Varela over 11 years ago

Giovanni Manghi wrote:

did you tested qgis master?

Yes, master fb7c596 works fine.

#3 Updated by Giovanni Manghi over 11 years ago

  • Resolution set to fixed
  • Status changed from Feedback to Closed

Rafael Varela wrote:

Giovanni Manghi wrote:

did you tested qgis master?

Yes, master fb7c596 works fine.

then we can close this, there are no backports.

Also available in: Atom PDF