I have an Excel file (with .xlsx
extension) containing some non-spatial data that I want to use in combination with some other spatial data.
I generally know how to load an external source (Loading Layers from the PyQGIS Cookbook), but I haven't found any reference for files with .xlsx
extension, so I tried to import it in this way:
uri = 'path_to_the_file/test.xlsx'
layer = QgsVectorLayer(uri, 'test', 'ogr')
but when I try to read something, for example, all the elements from the first column:
for item in layer:
print item[0]
I get this error:
'QgsVectorLayer' object is not iterable
What I'm doing wrong? If I previously converted my file to the .csv format, then there would have been no problem with the reading of the items in PyQGIS, but I would like to know if there is a direct way to avoid this passage.