I'm generating maps with QGis. What I do is generate a bunch of non-spatial data on a set of cities (using VBA), and still using VBA, generate a python code that will automaticaly output general map on the studied territory.
So far, I was importing the data into Qgis with the following code :
lyrData = QgsVectorLayer(u'C:/SomePlace/SomeFile.xlsx', ' ', 'ogr') QgsMapLayerRegistry.instance().addMapLayer(lyrData)
Which seemed to work, until it started to treat the header of the attributes/columns as data for some territories. Note that this bug is consistent : for some territories it will import header as header and for some it will import header as data...
I tried different things so far : If I import manually (without pyQgis), the bug is still here. I tried renaming the .xlsx file with the name of one that works, but it didn't work.
Another thing I tried is to import the file as an .csv instead of .xslx, but Qgis Cookbook only give exemple to import spatial data csv :
uri = "/some/path/file.csv?delimiter=%s&xField=%s&yField=%s" % (";", "x", "y") vlayer = QgsVectorLayer(uri, "layer_name_you_like", "delimitedtext")
uri = "file:///some/path/file.csv?delimiter=%s&crs=epsg:4723&wktField=%s" % (";", "shape")
And this, despite the fact that you can manually import CSV files without geometry
Using PyQGIS, is there a way to precise that imported excel files have an header, or is there a way to import csv files without geometry?