1

I am new to QGIS 3.0 and using "qgis:Joinattributetable" for joining .csv and .shp file. Below is my code, but I am getting Syntax Error.

AttributeError: module Processing has no attribute 'runandLoadResults'

I don't know how to fix this. Any suggestions?

vectorLyr=QgsVectorLayer("C:/Test/demand/Demand.shp","BuildingLayer","ogr")
vectorLyr.isValid()
uri='file:///C:/Test/data.csv?delimiter=,'
infoLyr=QgsVectorLayer(uri,'Population','delimitedtext')
infoLyr.isValid()
QgsProject.instance().addMapLayer(vectorLyr)
QgsProject.instance().addMapLayer(infoLyr)
shpField='FID_1'
csvField='FID'
result=processing.runandLoadResults('qgis:joinattributetable',vectorLyr,infoLyr,shpField,csvField,None)
  • @snaileater can yo help in this ? – ps1 Aug 31 '18 at 6:42
  • @ps1, can you please show us the Syntax Error that you end up with. – Taras Aug 31 '18 at 6:44
  • AttributeError: module Processing has no attribute 'runandLoadResults' – ps1 Aug 31 '18 at 6:48
  • qgistutorials.com/en/docs/performing_table_joins_pyqgis.html I am taking help of this and trying to join both data in Qgis3 – ps1 Aug 31 '18 at 6:50
  • @Taras I corrected it to processing.runAndLoadResults('qgis:joinattributetable',vectorLyr,infoLyr,shpField,csvField,None) , but now i am getting runAndLoadResults() takes from 2 to 4 positional Arguments but 6 were given. please help – ps1 Aug 31 '18 at 6:58
1

First of all, I think you need to modify your result because you misspelt it.

Secondly, .runAndLoadResults() takes only two parameters. In your case, the first one looks right and the second is wrong because it should be a dictionary with the necessary parameters.

Try this:

result = processing.runAndLoadResults('qgis:joinattributestable', parameters)

Hint: Set up your parameters = {}.

parameters = {'INPUT': vectorLyr,
              'JOIN': infoLyr,
...
}

And check these references as well:

|improve this answer|||||
  • Now i am getting module "processing" has no attribute runandload. – ps1 Aug 31 '18 at 7:10
  • 1
    Pay attention to the reference, where it says that processing.runandload() is for QGIS <= 2.18. Since you are deploying QGIS 3.0 you should use processing.runAndLoadResults(). – Taras Aug 31 '18 at 7:16
  • gis.stackexchange.com/questions/294406/… Can you see this and let me know what is wrong? I am using runandLoad as an alternative – ps1 Aug 31 '18 at 7:16
  • I already corrected that runAndLoadResults, but not sure how to write Parameter List – ps1 Aug 31 '18 at 7:18
  • 1
    Do not afraid to try and check QGIS documentation! – Taras Aug 31 '18 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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