"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…
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;
my ($j, $matched);
(my $amexvalues, my $amexdates) = read_file("amex.csv");
(my $ccvalues, my $ccdates) = read_file("clearcheckbook.csv");
my ($i) = 0;
$j = 0;
$matched = 0;
if ($amexvalues->[$j] == ($ccvalues->[$i] * -1))
$amexvalues->[$j] = "MATCHED";
$matched = 1;
$matched ? $j = scalar(@$amexvalues) + 1 : $j++;
print "CC $ccvalues->[$i] / $ccdates->[$i] not found in AMEX\n";
$i = 0;
if ($amexvalues->[$i] ne "MATCHED")
print "AMEX $amexvalues->[$i] / $amexdates->[$i] not found in CC\n";