Counting weeks (ISO 8601)

Using the ‘week’ as a time unit can be a bit confusing for at least two reasons:

  1. Does the week start on Sunday or Monday?
  2. How do you count a week that stretches two years?

Now probably your and anybody else’s take on those two questions will not just depend on cultural upbringing – but even more on – how it has been done so far. Nobody wants to change old statistics to a new counting or maintain two parallel statistics for one year with both countings. So to make a long story short, I’ll just stick with ISO 8601 standard because it seems reasonable to me. Here is what ISO 8601 has to say about the two questions:

Continue reading

Handling Excel files with PHP

There aren’t many cases where I would produce an Excel file with PHP – as almost always there is a better way to get your data where you need it. If I needed PHP processed data in an Excel file I would clearly recommend to feed the data into a database and fetch it using PowerPivot. But still I had and have occasional situations where taking this route is the most comfortable and / or efficient. Luckily it is actually pretty simple when you use PHPExcel. Considering that PHP is a bit odd and Excel is also a bit odd and open source software tends to be very individual (odd) it is no surprise that PHPExcel is also a tad odd – but after you got used it, you have a great tool at hand for handling Excel files with PHP.

Continue reading

Counting the frequency of ordered character pairs

I wrote this PHP script to count the character combinations for a previous post. This script is covering more functionality than I acutally used for the article. First I was fetching web-sites – using a service from www.alchemyapi.com which extracts the actual text information from a site. But after figuring that it was a bit tricky to choose a halfway representative set of web sites for a language, I took a short cut and just evaluated a big text file containing a classic novel for each language.

Continue reading