[Qgis-user] Getting file name from parameterAsFile

Nyall Dawson nyall.dawson at gmail.com
Wed Jun 27 15:37:13 PDT 2018


On Thu, 28 Jun 2018 at 00:45, Rudi von Staden <rudivs at gmail.com> wrote:

>         # trying to apply a filter to the input file by changing the subset parameter
>         uri = f"file:///{speciesPointsFile}?type=csv&xField=DDE&yField=DDS&crs=EPSG:4326&spatialIndex=yes&subsetIndex=no&watchFile=no&subset=%22Genspec%22%20%3D%20\'{genspec}\'"
>
>         filteredLayer =  QgsVectorLayer(uri, 'FILTERED_POINTS', 'delimitedtext')

Looks like this parameter HAS to be a .csv file for your script to
work correctly. In this case you should be using a
QgsProcessingParameterFile, with a csv extension, as your parameter,
not a QgsProcessingParameterFeatureSource (which could be any type of
layer, including non-disk based formats like memory layers or postgis
databases).

If you swap to a QgsProcessingParameterFile then parameterAsFile
should work as expected.

Nyall



More information about the Qgis-user mailing list