1

I'm making a script that can be called by the processing.execAlgorithmDialog function. For one of the parameters, I want to use the QgsProcessingParameterFile class for selecting a .csv file.

I tried the following:

class T4_Visualiseer_Networks_Resultaat(QgsProcessingAlgorithm):

    PrmOutputFile = 'Networks result'

    self.addParameter(
        QgsProcessingParameterFile(
            name=self.PrmOutputFile,
            description="Networks resultaat",
            extension="csv(*.csv)"
        )
    )

    def processAlgorithm(self, parameters, context, feedback):
        # Some code to do after clicking ok

When I select a .csv file in a folder and press OK to begin the script, I get the message Wrong or missing parameter value: Networks resultaat (see picture below).

enter image description here

I already tried the following:

  • Replace / by \
  • Add behavior=0 to make sure a file is selected (this was already the case because the default value for behavior is 0)
  • Rename the .csv file

None of the above actions fixed the problem of getting this message and I can't find any other solutions on the internet.

Do you have any idea what the problem can be or how I can fix it?

  • Does changing "CSV(.CSV)" to "CSV (.CSV)" help? (I.e. adding the space) – ndawson Jan 24 at 9:38
  • @ndawson Unfortunately this doesn't solve it – Hessel Koot Jan 24 at 9:46
0

In the code source you can read The extension argument allows for specifying a file extension associated with the parameter (e.g. "html"). Use fileFilter for a more flexible approach which allows for multiple file extensions. Only one of extension or fileFilter should be specified, if both are specified then fileFilter takes precedence.

Hence, you have to put the extension: "csv", "csv(*.csv)" is valid for the parameter fileFilter.

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

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.