0

i´ve a problem with a script, working fine until last month and there is no idea coming up what to do. I use PyCharm 2017.3.7 for this script because every Version above 2018.3.3 do not work with QGIS

It is a complete easy basic script, loading and saving a python project as a batch function to handle bad layers. But now the script kills all layers of my project so i get an empty one back. Any ideas for solving the problem. Maybe another code....

from qgis.core import *
import os
QgsApplication.setPrefixPath(r"C:\OSGeo4W64\apps\qgis-ltr", True)
qgs = QgsApplication([], False)
qgs.initQgis()


ordner = r"C:\Users...."

for root,dirs, files in os.walk(ordner):
    for file in files:
        if "QGZ" in file.upper():
            project = QgsProject.instance()
            project.read(os.path.join(root,file))
            QgsProject.instance().write()

qgs.exitQgis()

  • I'd check the return values of the project read and write calls first. – ndawson Jul 25 '19 at 21:56
  • The read and write call returns "True". So first of all it seems to work but it didn´t. – F.Tubbesing Jul 31 '19 at 10:00

Your Answer

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

Browse other questions tagged or ask your own question.