Friday, December 13, 2013


Poorly written programs are one of the greatest bothers. I myself wrote one such program apparently with a query which ran good the first time, but stubbornly refused to budge the second time. Now I am sure there would have been a mistake on my part, something which I overlooked, but what followed this has been well a nightmare (literally) as I spent a whole 6 hours trying to figure out a solution.

So, like any other programmer, I looked up google. Randomly, I had an idea to dump all my result set into a CSV, and then upload the CSV to MySql. Not as easy as it sounds. My table had 30000 entries, should have taken anything from 10 to 30 minutes to upload it through the in-built MySql utility.

But lady luck it seems eludes me in constant perpetuity.

The utility made my MySql Workbench crash after running for 30 minutes. Twice.

So, I began to look for more ways to upload/convert csv data to MySql. Now, what I found next was smart and nice, but essentially crude.

For instance, there are 8 different columns in my table. I opened the CSV file in MS-Excel, and wrote a formula to combine the data from the 8 cells into a well formatted SQL insert statement.

And, voila! I now have 30000 insert statements running in batches of 100. I believe it will take around 30 minutes to execute, but my MySql Workbench isn't crashing, and more importantly I am getting some work done.

I hear there's some research going on self-correcting programs, or where you specify just the algorithm and the IDE generates a program for you, but I fear that it will put programmers like me out of jobs, and there will be a state of anarchy, as that will also be the day, when the machines rise against the humans. Though I am quite curious, as to whether it will end up like The Matrix or the Terminator!