The Payroll File Was Full of @ Signs
When the agent says a file is corrupted, don't ask it for a fix. Ask what the file could be, with evidence, then check one value a human knows.
"They sent the file! Can you just let the AI read it? It reads everything."
Jonas wrote this on Thursday at 15:10, with three rocket reactions from the rest of sales under it. Jonas closed our biggest deal this year: a manufacturer with around 2,000 employees, and their payroll data was supposed to land in our system before their kickoff on Monday morning.
The file was called LOHN_EXPORT.DAT. 4.8 megabytes. No extension that means anything, no documentation, no header.
I opened it in my editor and saw garbage. Not a little garbage. The whole screen was boxes, question marks and random accents.
The agent says it is broken
I gave the file to the agent in our import repo and asked: "Write an importer for this file into our employee model."
It looked, and it came back very confident.
"The file appears to be corrupted or uses a non-standard encoding. I will read it as UTF-8 and replace invalid characters so the import can continue."
And it wrote exactly that. A Kotlin reader with CodingErrorAction.REPLACE, a parser that split lines on \n, and a test that was green because the test only checked that nothing threw an exception. The "imported" employees had names like �����.
I was really frustrated for a minute. Not because it did not know the format. I did not know it either. But because its plan for "I don't understand this data" was to destroy the data quietly and continue. If a junior did that, we would have a long coffee together.
Then Jonas came to my desk. "Is it working? I told them we can show their people in the system on Monday."
I said: "The file is fine. We are the ones who can't read it yet." He did not look calmer.
A different question
I deleted the branch and opened a terminal. Old habit: when text looks like garbage, look at the bytes.
$ xxd LOHN_EXPORT.DAT | head -n 1
00000000: e2c3 c8d4 c9c4 e340 4040 4040 c8c1 d5e2 .......@@@@@....A lot of @ signs. Everywhere. Every line in the dump had them.
I had a feeling, but no name for it. So I changed how I asked. No code this time:
Do not write code.
Here are the first 512 bytes of a file in hex.
List the possible encodings or formats, and for each one
the evidence in these bytes. Then tell me which bytes
I should find elsewhere in the file if you are right.This time the answer was the opposite of the first one. Calm, specific, and honestly a bit impressive.
It said the 0x40 bytes are spaces in EBCDIC, the encoding of IBM mainframes, and that is why they show as @ in ASCII. It decoded the first bytes for me: E2 C3 C8 D4 C9 C4 E3 is SCHMIDT, then spaces, then HANS. Since the customer is German, it said, the code page is probably 273 or 1141, which are almost the same and differ only in the euro sign. And there are no line breaks, so the records must have a fixed length. It suggested to find the length by looking for where SCHMIDT-like patterns repeat.
Then the part I did not expect. Some bytes in the middle of each record did not look like text at all, things like 00 04 51 20 0C. The agent said this looks like packed decimal, COMP-3 in COBOL: two digits in each byte, and the last half byte is the sign. C for positive, D for negative. So 00 04 51 20 0C would be 4512.00 if the field has two decimals.
I have written code for more than eighteen years. Java, C#, PHP, Kotlin, a bit of C++. I never wrote one line of COBOL. I knew EBCDIC existed the way you know fax machines exist. The agent had the whole thing in its head, ready.
The first answer was to destroy the data quietly. The second answer was a lesson in mainframes. Same agent, same file. Only my question was different.
One salary we already know
Now, a nice theory is still a theory. The agent was very sure the first time too.
So I did not ask it to write the importer yet. I wrote to the customer's payroll contact, Petra, a very patient woman who has run this export for many years. I asked her one thing: "Can you tell me the employee number, gross salary and entry date of the first person in the file?" She sent it in ten minutes, a bit surprised that someone asked her instead of guessing.
With that, I gave the agent a narrow job: decode only the first record, print every field with its offset, and compare with Petra's values. The packed decimal part was short:
fun unpack(bytes: ByteArray, scale: Int): BigDecimal {
val digits = StringBuilder()
bytes.forEachIndexed { i, byte ->
val b = byte.toInt() and 0xFF
digits.append(b shr 4)
if (i < bytes.lastIndex) digits.append(b and 0x0F)
}
val value = BigDecimal(BigInteger(digits.toString()), scale)
return if ((bytes.last().toInt() and 0x0F) == 0x0D) value.negate() else value
}The text fields we read with Charset.forName("IBM01141"), which the JDK supports out of the box.
First try: name correct, employee number correct, salary wrong. It showed 45120.0. The agent said "the scale is probably 1" and wanted to change it. I stopped it and asked: "What if the field starts one byte earlier?" It checked, agreed, and the salary became 4512.00. Exactly Petra's number. The date matched too, stored as plain EBCDIC digits YYYYMMDD.
Then the agent found something I would have missed. In about thirty records the salary ended with a D half byte. Negative. It asked if these could be correction entries and said we should not import them as employees with negative salary. I asked Petra. Yes: corrections from last month, they must be applied to the previous record of the same person. Nobody had told us this. It was not in any email. It was in the bytes.
By Friday evening we had an importer with real tests. Not "it does not throw". Tests with Petra's values for five people, including one correction and one name with an umlaut, because the umlauts are exactly where a wrong code page guess would break.
On Monday the customer saw their people in our system. Jonas sent a message with more rockets.
What I took from this one
- When the agent says "corrupted", change the question. Do not ask for a fix. Ask "what could this be, with evidence, and what would I find elsewhere if you are right?" It switches from fixing mode to thinking mode.
- Never accept silent replacement of data. I added a line to our
CLAUDE.md: in import code, never use replacement characters or skip bad records without an explicit error report. Unknown data must stop the import loudly. - Get one known value from a human. One record from Petra was worth more than any amount of clever decoding. The agent can make a beautiful theory. Only the person who owns the data can tell you if it is true.
- Decode one record before you write the importer. Small step, print every field with offset, compare. The off by one byte would have been invisible in a full import.
- Ask the business person what the strange values mean. The negative salaries were a business rule hidden in a format. The agent found them, but only Petra knew what they meant.
I still think about the first answer. The agent knew everything about EBCDIC the whole time. It just needed someone to ask it like an expert, not like a cleaning service.
What is the oldest file format an agent has helped you read, and did it get it right on the first try?

If this was useful
Telc German B1 Exam Success Kit (20/80 Rule)
The 20% of German that keeps showing up in the telc B1 exam. Learn it first and walk in already knowing what to expect. €7.99