Getting data out of an old system that can only send a file
By Custom Software Solutions ·
A lot of useful data is stuck in equipment that was installed long before anyone thought about dashboards. It does its job. It records what it should. It just has no modern way to share what it knows.
We recently built a daily operations dashboard for a water business. Most of its readings came from places that were easy to reach: a telemetry provider with an online data feed, and a regional council that publishes its river data in a form software can read. But some of the most important sites ran on older equipment, looked after by a contractor, and the only thing it could do was send a file.
Here's what it took to get those files flowing, and what we'd tell anyone in the same spot.
Give it somewhere safe to send to
The equipment could push a file over FTP or SFTP. FTP sends everything, passwords included, as plain text, so that was out. We set up an SFTP server with a login just for this equipment, allowed into its own folder and nowhere else.
That sounds like a small decision. It matters because this server is now part of the business's infrastructure. It needs to be hardened, kept up to date, and owned by the business rather than by us.
Agree the format line by line
The contractor sent an example file: semicolon-separated text, a header row, then one row per send. Before writing any code to read it, we went through every column with him.
That's where the real questions were. Was a "daily total" really a total, or a running count? Was a gate position in millimetres or percent open? Was a rain figure since midnight, or a rolling last 24 hours? Each answer changed what the dashboard should show, and none of them could be worked out from the numbers alone.
Rolling rain was a good example. The figure we were storing each morning turned out to be the last 24 hours up to the moment it was read, not yesterday's rain. Both are useful. They're not the same thing, and a report that mixes them up is quietly wrong.
The fault nobody could see
Then the equipment couldn't connect. It reported "connection to server failed" every time, and our server logs showed no attempt arriving at all. The server was fine: the contractor had logged in manually weeks earlier.
A packet capture found it. The equipment was sending full-size network packets that were being dropped somewhere along its mobile connection, and it never resent them. The odd small packet got through, which is why one attempt got as far as logging in and then hung.
The fix was one line on our server: tell connecting devices to use smaller packets on that port. Files started arriving straight after.
We mention it because this kind of problem is common with older and remote equipment, and it's easy to lose weeks blaming the wrong side. When a device says it can't connect and the server says nobody tried, look at the path in between.
Test data looks a lot like real data
For the first few days the files arrived on schedule, with numbers in every column. They weren't real. The header row still said "headings to follow!", and more than half the values were identical in every file, hour after hour.
Comparing several files across a couple of days made that obvious. Looking at one file never would have. We waited for the real headers and live values before showing anything to the client.
Plan for the equipment restarting
Two things changed whenever the equipment restarted. Its file numbering started again from one, and any totals it had been holding in memory were lost.
So the dashboard never relies on file names being in order. It keeps track of which files it has already read, and when each one arrived. And a reading that's out of date is shown with its date, never as if it were today's. A missing reading looks missing. A stale one doesn't pretend to be fresh.
We learned that last rule the hard way. For a short while, a bug in our own code fell back to an old test row when the latest one was missing, so two sites showed numbers that kept climbing. The contractor's files were right. Ours was the mistake, and the fix was to stop storing an old row as today's.
If you have data stuck in old equipment
- Ask what it can send, not what it can't. A file on a schedule is enough to build on.
- Use SFTP, not FTP, with a login that can only reach its own folder.
- Agree the meaning of every column with whoever looks after the equipment, in writing. Units, totals and time windows are where the mistakes hide.
- Compare several files over a few days before trusting any of them.
- Never show an old reading as today's. Show its date, or show it as missing.
- Keep the server and the accounts in your business's name. It's your data, and your infrastructure now.
If your staff check three or four systems every morning, we've written up how we get data into one place, and what it looks like for irrigation and water.