I am writing a plugin that offers to open a CSV. I know the local path to the CSV but I don't know if it contains spatial data nor which name the X
and Y
could have.
The best way I can think of, is to utilize the QGIS Delimited Text Widget and set the path to the file, so it is possible to choose X
and Y
(if existing) from the native dialog (and use the other functions if needed).
My only problem is, that I can't find a way to set the path to the file inside the widget. Is there a way I can do this?
The code to open the widget:
delimited_dlg = QgsProviderRegistry.instance().selectWidget("delimitedtext", self.main_win) # use iface.mainWindow() in console
QObject.connect(delimited_dlg, SIGNAL( "addVectorLayer( QString, QString, QString )" ),
self.main_win, SLOT( "addSelectedVectorLayer( QString, QString, QString )" ) )
delimited_dlg.show()
The native Class QgsDelimitedTextSourceSelect uses the variable txtFilePath
to store the path and the Class QgsDelimitedTextProvider takes the const QString& uri
as argument. Is there any chance I could set those?