Friday, August 5, 2011

The most frustrating program I've ever written



I think it's hard for anyone to take data in one format and get it into another to perform calculations. It's double hard when the language fights you a bit. I did everything I could to keep things "Pythony" but I'm still drastically unfamiliar with the language. I have a horrible suspicion that someone familiar with the language could do this in three lines of code.

Basically what the program does is this:
1) Read in a .csv file such that every row has its columns separated as individual elements in an array (Python list). Basically it makes a 2d array. List. Whatever

2) Remove the first row because it's the column names

3) Go through every row and copy over the ones that have something in the open date and close date columns. This makes a new list.

4) Take the new list and extract for each row the first and second column

5) Convert these extracted elements into a 3 element list

6) convert THAT list into a list of integers

7) convert that list of integers into a date and use it to calculate days between the close date and the open date

8) emit heavy sobs when it takes all damn evening to write, rewrite, write special simplified functions, rewrite again, insert a ton of print statements to get a handle on what's actually happening, finally figure out how to manipulate lists like you want, and then clean up any misc bugs and finally at your last nerve see it work.

I'm frustrated that I still don't know when to use classes vs a bunch of functions.

I'm frustrated that scope is horrifyingly ambiguous.

I'm frustrated that in a week I won't be able to read this code and make sense of it.

I'm happy that I tackled the hardest but most meaningful part of the analysis I want to do.

I can't balk at the fact it only took me a week to get well versed enough to first get through enough of LPTHW to comprehend the language and knock out the program. I started working on it this morning. I think I spent 3.5 hours on this total? Not bad, but it was an infuriating 3.5 hours. That time isn't counting when I walked away in frustration.

No comments:

Post a Comment