ExtremeCPA - Technology for Business

Monday, September 05, 2005

Scripting Languages

Well, hello to everyone! I'm so sorry I haven't written in so long. The wedding was fantastic, but took up a lot of my time :) Then, once I got back I was thrown right in the mix of school activities again, so even though I haven't written I've been a busy man.

I just wanted to write a quick post about scripting languages. You may have heard the term "scripting" before, or maybe not. If you know VBA (which some of my other posts have touched on), then you know scripting. But I also thought it might be a nice chance to step away from MS Excel for a moment and see what other technologies you can use to help do your job more effectively.

Script languages, as defined by Wikipedia are:
computer programming languages initially designed for "scripting" the operations of a computer. Early script languages were often called batch languages or job control languages. A script is more usually interpreted than compiled, but not always.

You really don't have to know what that means. All it says is that these tools are meant to help you control your environment more powerfully than, say, Excel. You can do many (if not all) the things you can do with a regular programming language: loops, conditional execution, etc. Why do I think you might be interested in this? Let's say that every month you are performing some type of reconciliation, and the file you reconcile to comes in a text form, but not a normal delimited file (i.e., not csv, not tab-delimited, etc.). You can see that it is clearly structured, but not in a way that Excel can recognize. In the past, you may have used a program like ACL or IDEA to define "records" and that are then processed to give you a comma-delimited file or something similar. This is where scripting could save you time and money.

The languages that I'll refer you to are (in order of my personal preference):
  1. Python
  2. Perl
  3. Ruby (never used, but heard it is very good)
You might even consider SQL a scripting language, but it is limited to databases whereas the 3 previously mentioned are ubiquitous. Also, as I mentioned before, VBA is a scripting language but it is limited 1) to the Microsoft environment and 2) Typically to Microsoft programs like Excel or Word (although you can use it elsewhere, I never have).

All 3 programs are open source (and therefore free as in beer and free as in speech), so you will never be limited to a vendor and you will never be constrained by a licensing cost or issue. And all 3 languages are EXTREMELY powerful. The task previously mentioned could easily be handled by anyone with at least a minimal proficiency in any of the three languages. After downloading (e.g., Python) you can write a program to open a text file and process every line in the file as follows:

f = open("file_name", "r")
for line in f:
#process line

This would indicate the filename was "file_name", the "r" indicates that you want to open the file for "r"eading, and the "f" is simply a variable. The "for line in f:" is a looping construct that reads every line in the file. The "#process line" would be replaced by some suitable code that would process each line (perhaps adding a total to the previous total, etc.). Finally, you close the file with f.close().

As you can see, with just a little more cursory knowledge, you can do some pretty powerful things fairly easily. I'll continue sometime next week with an additional discussion of Python, but I suggest that you check out the websites above if you are at all interested thus far. Don't be intimidated! It is fairly easy to get going, once you give it a shot. Good luck!


Post a Comment

<< Home