A roundabout WTF



  • I was called upon to fix a problem in a system that was created years ago. I use the term "system" loosely, as it's just a bunch of separately-written pieces that somehow work together.

    One of the projects in my company uses a website developed in-house that submits user-entered data to a public government website, which generates a bunch of poorly-delimited text files. The in-house website will automagically download all the files and store them on a network share, where the user downloads them to their own computer and then re-uploads them to the same site to run through a parser OCX which converts them to something resembling XML. It's supposed to be XML, but isn't quite compliant. Those XML-eque files are used in other home-grown software packages to do their jobs.

    Makes sense so far, right?

    The problem came in when the public government website ran into an error with their file-generating code. This tends to happen for a few hours every Monday morning, but this time it was down for two days. You can choose to have the results display in HTML on the page, or go with the text file. Someone noticed that if you opt for HTML, it works fine every time. So the idea was put forth that I fix the code so it downloads the HTML version and formats it to match what the text file should look like.

    Unfortunately, the HTML isn't exactly formatted well. There are tables nested within tables nested within tables, sometimes multiple fields are concatenated into one <td> field which makes them difficult to parse, sometimes there are four <td>'s in a row where the text file only had two values...ugh it's a headache. I can't figure out the logic or any simple conversion that won't require a lot of hard-coding.

    But I suggested that I just revamp the thing, make it download the results, convert them to this XML-ish format, and present the user with a single link to a zip file of their data. I checked out the file-downloading code, the horrid OCX abomination which converts these files, and gave my time estimate. Nope, not enough funding to support such a drastic change, only enough time and money for me to fix this particular issue.

    Probably all for the best. Here is my favorite part of the OCX code:

                Dim x() As String
                Dim y As Integer
                             
                y = (0)
                y = (1)
                y = (2)
                y = (3)
               
                x = Split(replacestring, ",")

    First set y to a bunch of different values. No comments why this was done, no reasoning. I can't say I've put parenthesis around numbers like that before unless I'm actually doing something to them, but that's just my preference. y is later used to reference a particular array element in x, which is created with the ever-popular "Split" function. Commonly used for delimited data, but not exactly 100% accurate, is it?

    This project continues to run, not because of the lack of errors in the data, but only because no one has caught them yet.



  • Is it getting hard to remember why you wanted in the I.T. field? :)

    Why don't you tell the user just to copy the HTML from the screen and paste it into Notepad? (If I'm reading your description right, I'm only half joking. But I think I'm missing something.) 



  • [quote user="Manni"]

    Unfortunately, the HTML isn't exactly formatted well. There are tables nested within tables nested within tables, sometimes multiple fields are concatenated into one <td> field which makes them difficult to parse, sometimes there are four <td>'s in a row where the text file only had two values...ugh it's a headache. I can't figure out the logic or any simple conversion that won't require a lot of hard-coding.

    [/quote]

     Just load the page into Lynx, tell it to print to a text file, which basically does the same thing as copying and pasting into Notepad. Then you can parse a bunch of poorly laid out text instead of horrible HTML.



  • You must work at the same Gov't agency I do... otherwise I'm moving to another country.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.