Porting My 20-Year-Old Excel Models to Python

This is part five of my series on rebuilding my old daily fantasy lineup optimizer (the series kicks off with how I got into this). The earlier posts were about the math. This one is about the move itself: taking a model that lived in an Excel workbook for over a decade and turning it into a web app anyone can use without installing anything. It’s the same journey I’m making with all my old Operations Research models, one at a time.

Diagram of porting an Excel and Solver model to a Python and Flask web app

What the Excel version actually was

The old tool was a workbook. The player pool sat on one sheet, the salary cap and roster rules were laid out as constraints, and an add-in solver chewed through it to produce a lineup. Around that core was a thick layer of VBA macros doing the unglamorous work — importing the player file, formatting things, and in the worst-aged part, automating an old web browser to actually enter the lineups. It worked, but it only worked on my machine, with my Excel, with the add-in installed and the macros enabled. Handing it to a customer meant handing over all of that and hoping their setup matched mine. That fragility is the whole reason it eventually stopped being usable.

The good news: the engine barely changed

Here’s the part that surprised me in a good way. The actual optimization engine in Excel’s Solver and the open-source solver I now use in Python are close cousins — both are the same family of solver doing the same kind of math. So porting the model wasn’t a rewrite of the hard part; it was a translation. The constraints that were spreadsheet formulas became a few lines of Python. The salary cap, the roster counts, the position handling — all of it mapped over almost one-to-one. Twenty-year-old modeling decisions held up fine. The math was never the problem; the packaging was.

What I threw away

The entire automation layer went in the bin, on purpose. The new tool only does one thing: it generates lineups. It doesn’t log into your account, it doesn’t enter contests, it doesn’t touch your money. You upload the salary file you already download from the contest site, the tool optimizes, and you download a file to upload back yourself. That’s a cleaner and safer boundary than the old “let the spreadsheet drive a browser” approach ever was — and it sidesteps the brittle automation that killed the original. Less code, fewer ways to break, nothing that depends on a particular browser being alive.

Why a web app instead of a better spreadsheet

I could have just modernized the workbook. I didn’t, because the spreadsheet’s biggest flaw was never the math — it was that you needed to be me to run it. A web app erases that. There’s nothing to install, nothing to enable, no add-in, no version to match. You open a page, upload a file, and it works the same on any computer or phone. That’s the difference between a tool I can use and a tool anyone can use, and it’s the entire reason I’m doing these rebuilds in the open instead of just fixing my own private copies.

What’s actually doing the work now

For anyone curious about the parts, none of it is exotic. The optimization is written with a free Python library called PuLP, which lets you describe the model — variables, objective, constraints — in plain code and hands it to a solver called CBC to crunch. CBC is open-source and, importantly, it’s the same kind of solver that sat behind Excel’s add-in the whole time, so the results line up with what the spreadsheet used to produce. The web part is a small Python framework called Flask, which turns “run this function when someone uploads a file” into an actual page. That’s the entire stack: describe the model, solve it, show the result. No machine learning, no secret sauce — just operations research wearing a website.

Where it lives

The whole thing runs on a small cloud server that costs me next to nothing and stays awake waiting for anyone to drop in a file. There’s no database, no accounts, nothing stored — you upload, it solves in your session, you download, and it forgets you. That’s deliberate. Part of why these rebuilds are even possible now is that hosting a little app like this has gotten cheap and boring, in the best way. In 2012, putting a tool like this online for strangers would have been a project in itself; today it’s an afternoon, which is exactly why I can afford to give it away.

Why I’m doing this in the open

This optimizer is one of a string of these conversions. I’ve already put a vehicle routing optimizer and a staff scheduler online the same way, with a Roth conversion model in the queue behind them. The pattern is always the same: a model that solved a real problem, trapped in a spreadsheet only I could run, freed onto a page anyone can. Writing them up keeps me honest about how they actually work, and it’s more fun to explain the thing than to hoard it. The Fiverr version was a product; this version is a portfolio of free tools and the stories behind them.

The one part that genuinely needed care in the port was the file handling on both ends — reading the exact salary export each contest site produces, and writing a file formatted precisely the way they expect it back. Get a single column wrong and the upload bounces. That unglamorous plumbing, not the optimization, is where most of the rebuild’s hours actually went.

The translation was the satisfying part of this project. The frustrating part came after, when the thing ran perfectly on my laptop and then completely refused to work the moment I put it on a real server. That story — a full day lost to a bug that only appeared in production — is the next and final post in the series. In the meantime, the result of all this is live and free: the MLB lineup optimizer, no spreadsheet required.

Tradeline Supply
Things that I use, like, and am affiliated with:
Mint Mobile offers great cell phone service for $15 flat, get $15 off using the link. Get discounted phones with service activation and no contract.
I never spend money before I check Mr Rebates or Rakuten to get cashbacks, rebates, discounts, coupons or cheaper gift cards.

Leave a Reply