Skip to main content

I have a PythonCaller with a script using the unumerate function.

In my Python IDE, it works fine. In my FME project on my laptop either.

 

But, when I copy it in a FME project on another computer (VM actually), the enumerate line seems to be passed without an error message.
 	finalFieldListOutput = r]
        with open('formDataOutput.txt') as myFile:
            logger.logMessageString("2dans le with IIIIIIIIIIIIIIII")
            for number, line in enumerate(myFile, 1):
                logger.logMessageString("2dans le for OOOOOOOOOOOOOOOOO")
                if 'FieldName:' in line:
                    logger.logMessageString("2dans le if FFFFFFFFFFFFFFFF")

In the FME logger, there is just "2dans le with IIIIIIIIIIIIIIII".

 

In all the situation, I'm using Python 2.7. So I cannot see where is the problem.
It seems that there is no problem in the script. Did you check whether the source text file actually contains some lines?

 


I'm guessing that "myFile" is empty on your VM, in which case enumerate() does nothing.

Maybe try logging the contents of "myFile" on line 3 and check:

logger.logMessageString("myFile: " + repr(myFile.readlines()))


I'm guessing that "myFile" is empty on your VM, in which case enumerate() does nothing.

Maybe try logging the contents of "myFile" on line 3 and check:

logger.logMessageString("myFile: " + repr(myFile.readlines()))

error message : 

 

TypeError: cannot concatenate 'str' and 'list' objects

 

and if remove the string, I have : 

 

TypeError: must be string, not list

 

 


Probably specify input file by full path?


I'm guessing that "myFile" is empty on your VM, in which case enumerate() does nothing.

Maybe try logging the contents of "myFile" on line 3 and check:

logger.logMessageString("myFile: " + repr(myFile.readlines()))

I saw the FME API documentation but, I can't figure out what is the right one.

 

 


It seems that there is no problem in the script. Did you check whether the source text file actually contains some lines?

 

Actually, I can't figure it out how to check by the logger.

 

 


error message :

 

TypeError: cannot concatenate 'str' and 'list' objects

 

and if remove the string, I have :

 

TypeError: must be string, not list

 

 

Fixed the typo, should work now

 

 


Fixed the typo, should work now

 

 

myFile: :]

 

You all were right...

 

 


Actually, I can't figure it out how to check by the logger.

 

 

Follow David's suggestion.

 


Finally it was, indeed, a problem of empty file. The real cause was far among this lines. My FME project is linked to another software of my company. This sogtware was unable to let run a system command. But problem solved. Thanks guys.

 

 


Reply