I am trying to use Processing tool to automate refactoring for several tables: here is the code I am trying to use
import processing
input = 'C:\\Users\\Ehsan\\Desktop\\CIS WORK\\Sample
files\\GeoJason\\cable.geojson'
output = 'C:\\Users\\Ehsan\\Desktop\\CIS WORK\\Temp\\'+'cable'+'.geojson'
processing.run("qgis:refactorfields",
input,
[{'name': 'id',
'type': 10,
'length': 10,
'precision': 0,
'expression': 'Value'
}],
output)
When I run this program I get the following error:
Traceback (most recent call last):
File "C:\PROGRA~1\QGIS3~1.2\apps\Python36\lib\code.py", line 91, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "<string>", line 14, in <module>
File "C:/PROGRA~1/QGIS3~1.2/apps/qgis/./python/plugins\processing\tools\general.py", line 96, in run
return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
File "C:/PROGRA~1/QGIS3~1.2/apps/qgis/./python/plugins\processing\core\Processing.py", line 128, in runAlgorithm
context = dataobjects.createContext(feedback)
File "C:/PROGRA~1/QGIS3~1.2/apps/qgis/./python/plugins\processing\tools\dataobjects.py", line 72, in createContext
context.setFeedback(feedback)
TypeError: QgsProcessingContext.setFeedback(): argument 1 has unexpected type 'str'
processing.run("qgis:refactorfields", {'INPUT':'/home/bera/GIS/Testdata/Polygons123.shp','FIELDS_MAPPING':[{'expression': '"id"', 'length': 10, 'name': 'id', 'precision': 0, 'type': 4}, {'expression': '"someid"', 'length': 100, 'name': 'someid', 'precision': 0, 'type': 10}],'OUTPUT':'/home/bera/GIS/Testdata/Polygons123_refactor.shp'})
Input should be inside curly brackets etc.