How to load a data table as a 'vector layer' using PyQGIS?
The following snippet works for me:
uri = "file:///C:/testdata/somecsv.csv?delimiter=%s" % (";")
lyr = QgsVectorLayer(uri, 'New CSV','delimitedtext')
QgsMapLayerRegistry.instance().addMapLayer(lyr)
For reference, if you wanted to add it with geometry:
uri = "file:///C:/testdata/somecsv.csv?delimiter=%s&crs=epsg:4326&xField=%s&yField=%s" % (";", "x", "y")
lyr = QgsVectorLayer(uri, 'New CSV','delimitedtext')
QgsMapLayerRegistry.instance().addMapLayer(lyr)
Most importantly, make sure the correct delimiter has been specified!
Wow. Way simpler than I expected. Should not have supposed that 'ogr' wouldn't be able.
someTableLayer = QgsVectorLayer(ministryOf.csv, 'sillyWalks', 'ogr')
QgsMapLayerRegistry.instance().addMapLayer(someTableLayer)