Blog News

Fun Project : visualisation of all the flemish schools

I’ve had a bit of fun recently with visualising some open data from where I downloaded the address list of flemish schools for kindergarten and “lower” schools.

  • imported the csv list via “base” in an sqlite database
  • added longitude and latitude fields to the db
  • wrote a small script that used geopy to query google for each address and add the coordinates to the db
  • then created another small script using pygmaps to create a custom html file which includes the necessary coordinates for each point on the google map.

The result is that I never knew how many schools there were in Vlaanderen !

Schools in Flemish Belgium

You can read more in the original post (in Flemish) that I made on the dataconnect website, where I advertise for my web site design and consultancy. For the full map, click on the above image to go there.


WeightManDesktop, an AIR application for Weightman (iTunes)


Here’s a small application called WeightManDesktop that I wrote as a proof of concept to see how difficult it was to import a csv file and process it in actionscript. I blogged about it earlier here.

It uses the csv file that is generated by WeightMan (iTunes link), a free iPhone program that allows you to note your weight over time intervals. Weightman allows you to export your entries in csv and sent them by mail to your desktop. I wanted a desktop application that could display all the entries in one go.

The iPhone app is made by Katachi studios. I did try to contact them to let them know I was posting this, but as their site is partly in japanese and there is only a small english page, I couldn’t find the contact email… [update: I managed to contact them, and they seem happy with it 🙂 ]

To use the program, use the install badge below – it’s an AIR application, so you need to first install the run-time air player as well if you haven’t done so before. I’ll make a proper install badge for it sometime in the future if or when I revise the program.

Use the source button on the bottom of the screen to locate the csv file and import it. Two graphs will then be shown, one showing your weight and one showing your body mass index level, as calculated by Weightman.  There’s a toggle button to show only the last 30 entries as well.

It’s a very basic first release, but I may add additional functionality it in the future. If you would like an improvement or see something to fix, please leave a comment.

[Update: link changed to point to version 0.2 – changes are described here]

[airbadge] WeightManDesktop,, 0.2,[/airbadge]


Reading and Displaying a csv file using Flex (AIR) and Actionscript

I’ve already written a python script that can convert a .csv file to a .xml file, which quite a few people seem to like. This is a good solution when you have a large file to convert.

But really, reading a small and simple csv file directly into Flex/Flash to use it in charts or display the contents in a DataGrid would be a “Nice To Have” solution. Plus, I’ve noticed that over the years I reuse my code and each time I add new functionality to it; now is the time to start with it !

So I made an AIR application ( for the simple reason that I load a local csv file) that does exactly that. The AIR app is called WeightManDesktop.

Since I know it’s a small file that I’m loading, it doesn’t matter that I load it completely into memory. For a larger file, in Python I would typically open the file for reading and read it line by line, processing each line as I go.

Using the File.browseForOpen AIR functionality, I read in the file selected by the user into a string and then process the content in a seperate function:

// Read in the selected file when the file is selected
private function openfileSRCHandler(event:Event):void{, FileMode.READ);
content = String(fileStream.readUTFBytes(fileStream.bytesAvailable));
trace(“*** File loaded.”);

Using the strings split function, I first split the string into seperate lines using the line seperator to split them. Each line thus becomes an Array. I then split each line into seperate content, again using the split function using commas to seperate them into the seperate items. These items are then added to an ArrayCollection that I’ve previously defined.

private function processContent():void {
//var ending:String = new String(“\n\g”);
// Split the whole file into lines
var values:Array;
var lines:Array = content.split(“\n”);
trace (“File split into ” + lines.length + ” lines”);
// Split each line into data content – start from 1 instead of 0 as this is a header line.
for ( var i: Number=1; i < lines.length; i++ ) {
var line: String = lines[i];
values = line.split(“,”);
trace (“line split in ” + values);

// Add values to arraycollection
linedata.addItem({date:values[0], weight:values[1], bmi:values[2], workout:values[3]});

And that’s it. Use the ArrayCollection as a dataprovider for your datagrid and Bob’s your Uncle !


Version 1.8 of CSV2XML is out

Thanks to a comment from a user of the program who had problems getting the script to process csv files on the mac, I’ve updated the script to version 1.8 so it will now open them without first needing to save the file in unix format when exporting to csv from Office for Mac.

For those of you who noted the version skip, version 1.7 has not been released, but just includes a simple test to see if the first field is empty or not. If empty the line is dropped. It’s been commented out in the latest version. Since my hosting provider also does python, I have renamed the file to .txt. Simply rename it to .py to have it working.


[For the Pythonistas : I’ve set the csv module to now open the files in read ‘universal’ mode]