I have a large number of parameters and they all need to be pre-assigned. However, the content of the parameters can change. Therefore a variable solution is needed
Yes you can, using a Python Scripted Parameter.
Create an .ini file, for example FmeConfig.ini with the following contents.
tSection1]
Setting1 = Value1
Setting2 = Value2
=Section2]
Setting3 = Value3
Setting4 = Value4
nSection3]
Setting5 = Value5
Setting6 = Value6
In FME, create a Scripted Parameter, Section1_Setting1.
import configparser
config = configparser.ConfigParser()
config.read(r'C:\TMP\FmeConfig.ini')
return config.get('Section1', 'Setting1')
This wil set the parameter Section1_Setting1 to Value1.
If you have a lot of parameters, this will take some time to set up, but it will do what you asked for.
Hello nielsgerrits,
Thank you for the quick reply. Das Script works nice. But now I have a new problem.
Sorry, I am just a beginner. When I pass words with umlauts (ä, ü, ö etc.) as values, they are not displayed correctly. Also an AttributeEncoder does not translate the values to UTF8.
Do you have a solution here too. Thank for your help.
Hello nielsgerrits,
Thank you for the quick reply. Das Script works nice. But now I have a new problem.
Sorry, I am just a beginner. When I pass words with umlauts (ä, ü, ö etc.) as values, they are not displayed correctly. Also an AttributeEncoder does not translate the values to UTF8.
Do you have a solution here too. Thank for your help.
Ah encoding, can you try if the following code works for you?
import configparser
config = configparser.ConfigParser()
with open(r'C:\TMP\FmeConfig.ini', encoding='utf-8') as f:
config.read_file(f)
return config.get('Section1', 'Setting1')
Hi nielsgerrits,
great, that's the solution. You are the best. Thanks
Hi nielsgerrits,
great, that's the solution. You are the best. Thanks
To be hones, I only implemented an ChatGPT answer, but if it works, it works :)
OK good idea, next time I'll also try chatGPT first, but if not I'll be back in the forum. Thanks 🤔