why you should be able to code

4 09 2009

"Coding" is what people call programming these days, and it is used in just about every context of utilizing a structured language to automate something on a computer.  There are more syntax types and languages than I can even imagine out there, so knowing them all is basically impossible.  What is quite possible is at least understanding the basic logic to be able to write something with them.  The ability to learn at least one or two, and actually use it is an invaluable tool in life.  I use the ability to manipulate data in an automated fashion very regularly at work, and it has saved me thousands of hours of manual labor in return.

Why do I think everyone should know how?  Well, I’m going to tell you.

Lori and I sit down once a month to update all our various financial accounts from the past month.  This includes purchases, interest earned, principal paid, etc.. etc..  We use http://www.clearcheckbook.com and find it great for storing what we need.  BUT last night something horrible went wrong.  The total outstanding value on our American Express card differed by $225.81 from what was calculated in ClearCheckbook.  We went over it multiple times and couldn’t figure it out.  In my frustration last night, I downloaded excel (Amex) and comma separated (CC) files representing our purchases from the last two months.  I opened them in Numbers and pasted them side by side, then proceeded to actually drag the values next to each other.  Well, they all matched, we hadn’t missed a thing.

So tonight, I downloaded the entire 2.5 year history of the account from both places, exported them both to CSV and put them on the desktop on my mac.  I then wrote a perl script to compare the two.  I know.. many (well, those who know what it is?) of you would use diff, but it would have required sorting the files by dollar value, and would have removed some of the functionality around dates that I was looking for.

I could very clearly print out in chronological order, the entire history of both accounts and how they differed.  This is why you need to know how to program.

Of course, I still found no differences, and it turns out American Express fixed a math error on their side so that everything matches.  Meaning… if you didn’t know how to program it would have just all fixed itself and you wouldn’t have wasted all your time like I did.  Grumble..  but at least I got to practice perl for the first time in a while.


Anyways, for posterity…



use strict;

sub read_file
  my ($line, $date, $value);
  my (@values, @dates);

  (my $file) = @_;
  open(FILE, "< $file") || die "failed $!\n";
  my @data = <FILE>;

  my $i = 0;

  foreach $line (@data)
    $line =~ s/"//g;

    ($date,$value) = split(/,/, $line);

    $values[$i] = $value;
    $dates[$i] = $date;


  return(\@values, \@dates);

my ($j, $matched);

(my $amexvalues, my $amexdates) = read_file("amex.csv");
(my $ccvalues, my $ccdates) = read_file("clearcheckbook.csv");

my ($i) = 0;

while ($ccvalues->[$i])

  $j = 0;
  $matched = 0;

  while ($amexvalues->[$j])
    if ($amexvalues->[$j] == ($ccvalues->[$i] * -1))
      $amexvalues->[$j] = "MATCHED";
      $matched = 1;

    $matched ? $j = scalar(@$amexvalues) + 1 : $j++;


  if (!$matched)
    print "CC $ccvalues->[$i] / $ccdates->[$i] not found in AMEX\n";


$i = 0;

while ($amexvalues->[$i])
  if ($amexvalues->[$i] ne "MATCHED")
    print "AMEX $amexvalues->[$i] / $amexdates->[$i] not found in CC\n";



4 responses

4 09 2009


4 09 2009


4 09 2009

@mikeb – :)

4 09 2009

Two positives I see to not using Mint.com (although, I agree – it is cool);
1) checks and balances to charges that are active rather than passive. *I* have to add it, if it’s not there it is raised to my attention. With Mint.com I have to go find anything that looks funny. This one is probably arguable that I waste more time entering values than I would probably save in the checks and balances, but I’m anal like that..
2) My entire financial account information is not centally stored on something I don’t run. I have no trust in them not being hacked.. This is the real reason I haven’t compromised on #1 and gone Mint.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: