Main Content

The power of scripting

Archive - Originally posted on "The Horse's Mouth" - 2016-01-12 19:18:07 - Graham Ellis

Over the last few days, I've been helping to populate the Option 24/7 web site - suggesting an alternative to Beeching Style cuts to save money on bus subsidy - by looking at the network as a whole rather than individual routes.

Example - don't run all buses the same route between two major towns - 2 buses an hour is more than the intermediate villages need, rather one an hour is fine and have the second bus take a different route - perhaps even vary it on alternate hours - so that the services fan out and fan in again, removing the need for an infrequent intermediate bus.

Example .... hey - there are examples on the option247 web site - this blog is about the power of scripting.

I needed to extract a column of data from a downloaded file - so that I could write to Parish and Town Clerks around the county, and alert the to our "write-in" option. Big edit? No - little script!

  <?php
  $fh = fopen("ParishCouncillors.csv","r");
  while ($record = fgetcsv($fh)) {
    print ("$record[9]\n");
  }


And the job is easily done. You may wonder why I used PHP ... well, it's a change from all the Perl 6 and Python I've been doing this month, I was doing some PHP work for a PHP course I'm running next week, and I could remember the format of the fgetcsv function in PHP.