Skip to main content
Question

Apply Python Script to several Excel Files

  • September 18, 2025
  • 2 replies
  • 41 views

lambertus
Enthusiast
Forum|alt.badge.img+23

I have a table that I need to export to an Excel file. To this file I want to apply some styling. I’ve written a Python script that works well: it uses a FeatureWriter followed by a PythonCaller, and the result is an Excel file with the desired formatting, including filters, colors, and so on.

Now I’d like to split this Excel output using a fanout expression, which generates 23 separate Excel files. Each of these files should then be processed by the PythonCaller. However, that’s where things go wrong — the process seems to get stuck. I’m using the _dataset variable from the Summary output port of the FeatureWriter as the location for the Excel files, which the PythonCaller should loop through.

Is there something I might have overlooked?

2 replies

alexbiz
Influencer
Forum|alt.badge.img+28
  • Influencer
  • September 18, 2025

Hey Elbert, 

that’s where things go wrong — the process seems to get stuck.

Could you elaborate? Do you have any logs to share?

Keep in mind that Excel files are locked while they are open by another process. Maybe your Python script is trying to access a locked file?


lambertus
Enthusiast
Forum|alt.badge.img+23
  • Author
  • Enthusiast
  • September 19, 2025

@alexbiz thanks for your reply. I am not sure, but I had the same reasoning that maybe FME got stuck because it tried to open Excel files, edit them and save creating a lock somehwere. I changed my script a little in order to not overwrite my original Excel files but create new ones: (Excel_file)_styled.

Now it works perfect