I am trying to delete an intermediate file ("Temp_merged.shp") after running the singleparts to multiparts algorithm in QGIS 2.18.
import glob, os, processing path_to_shp = "C:/Temp/Tracks/" os.chdir(path_to_shp) for fname in glob.glob("Temp_merged.shp"): merger = "Temp_merged.shp" processing.runalg("qgis:singlepartstomultipart",merger,"Unique","Multipart.shp", progress=None) del merger os.remove("Temp_merged.shp")
However, I am getting the following error:
[Error 32] The process cannot access the file because it is being used by another process: 'Temp_merged.shp' See log for more details
How can I end the processing.runalg to delete the intermediate shapefile?