I need to check the encoding of several files.
For this I can use a scripted parameter like so:
featureType =open('F:\\PGV\\Projektarbejdsmapper\\P4\\SCSV_til_kontrol\\scsv_2021e1_2021e3\\\\2021e1_lev_k_fortidsminde.scsv')
t = str(featureType)
return t
With a Creator and a ParameterFetcher i get the following attribute:
<_io.TextIOWrapper name='F:\\\\PGV\\\\Projektarbejdsmapper\\\\P4\\\\SCSV_til_kontrol\\\\scsv_2021e1_2021e3\\\\2021e1_lev_k_fortidsminde.scsv' mode='r' encoding='cp1252'>
When I try to do this with a useparameter like so:
file = FME_MacroValuesl'SCSV_file']
featureType =open(file)
t = str(featureType)
return t
This returns the following log:
Starting translation...
INFORM: Using Python interpreter from `C:\\Program Files\\FME\\fmepython38\\python38.dll' with PYTHONHOME `C:\\Program Files\\FME\\fmepython38'
INFORM: Python version 3.8 loaded successfully
ERROR : Python Exception <KeyError>: 'SCSV_file'
INCLUDE -- failed to evaluate Python script `def ParamFunc():
file = FME_MacroValuesa'SCSV_file']
featureType =open(file)
t = str(featureType)
return t
value = ParamFunc()
macroName = 'test_script'
if value == None:
return { macroName : u'' }
else:
import six
try:
value = six.text_type(value)
except UnicodeDecodeError:
value = six.text_type(value, 'utf-8')
return { macroName : value }
'
Program Terminating
Translation FAILED.
Why does my scripted parameter fail, when I use a User Parameter (text) as input ?