I’ve been building a Power Automate flow that ingests large CSV files (5,000+ rows) and transforms them into structured Excel tables using Office Scripts. My original script parsed the CSV and wrote rows one-by-one, then applied removeDuplicates, AutoFilter, and table creation directly in the workbook.
This worked for small files but consistently failed for larger datasets with the error:
The Run script action in Power Automate has a ~120-second synchronous timeout, and my script was hitting that limit due to excessive workbook I/O.504 BadGateway Your Office Script has timed out. Please try again.
I needed a solution that:
- Handles large datasets without timing out.
- Performs deduplication, filtering, and cleaning.
- Creates a final Excel table for downstream processes.
Has anyone solved this problem or can share best practices for optimizing Office Scripts in Power Automate?

Report
All responses (
Answers (