I'm trying to run the following algorithm which runs fine when I select a layer I imported from the CSV file in question but not when I just try to run if from the file itself.

input = '/media/path/points.csv=csv&detectTypes=yes&xField=long&yField=lat&crs=EPSG:103172&spatialIndex=no&subsetIndex=no&watchFile=no'

layers = QgsProject.instance().mapLayersByName('points')
#input = layers[0]

output = '/media/path/outline.shp'

params = { 'DATE_FORMAT' : '', 'GROUP_FIELD' : 'rid', 'INPUT' : input, 'ORDER_FIELD' : 'vertex_ind', 'OUTPUT' : output }

res = processing.run('qgis:pointstopath', params)

I'm getting:

File "/usr/share/qgis/python/plugins/processing/core/Processing.py", line 137, in runAlgorithm raise QgsProcessingException(msg) _core.QgsProcessingException: Unable to execute algorithm Could not load source layer for INPUT: /media/path/points.csv=csv&detectTypes=yes&xField=long&yField=lat&crs=EPSG:103172&spatialIndex=no&subsetIndex=no&watchFile=no not found

  • 1
    Try replacing layers = QgsProject.instance().mapLayersByName('points') with layers = QgsVectorLayer("file:///" + input, "point", "delimitedtext") and then replace 'INPUT' : input with 'INPUT' : layers in params.
    – Joseph
    Commented Aug 12, 2019 at 14:36
  • This seems to get me closer, it looks to be reading the file but now I'm getting: TypeError: 'QgsVectorLayer' object is not subscriptable
    – Sean
    Commented Aug 12, 2019 at 16:52

1 Answer 1


With Joseph's insight this is what worked.

input_uri = 'file:////media/path/points.csv?delimiter=,&xField=long&yField=lat&crs=espg:103172&spatialIndex=no&subsetIndex=no&watchFile=no'
output_uri = '/media/spath/out_paths.shp'
lyr = QgsVectorLayer(input_uri, 'New CSV','delimitedtext')

params = { 'DATE_FORMAT' : '', 'GROUP_FIELD' : 'rid', 'INPUT' : lyr, 'ORDER_FIELD' : 'vertex_ind', 'OUTPUT' : output_uri }
res = processing.run('qgis:pointstopath', params)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.