Archive for python

First bite of data.gov.in datasets

We turned up at the announced event through the facebook events page , had no clue who the organizers were and the place we were going to . The page just mentioned about telling stories with data. Staying with the open data community i had a clue of what was coming , but did not have a clear agenda or plan of action for next few hours we were going to stay at the meetup.One of the datasets i have been hearing about a lot past few months  is from the data.gov.in website , since my rendevous with the Open Data from govt has been limited to the public data available through chalobest.in project , this project still has not been realized in  NCR area. Anyway the place was a buzz with people of all age groups mostly students from journalism and activists too . we all sat in small groups either talking about an idea or data set we would be working on . Since i was interested in the data sets from Govt , we picked the infant mortality rate  it was in CSV format , the big picture was to create a Heatmap out of  the data available , the first thing we noticed was there were not lat longs for the states , so two members from team @arcolife  and Myself sat down with the site Geonames.org to collect  the same , in the meantime @bhanuvrat , @kanteshraj were writing scripts to the data transformed  in the format required . Ramniq was our anchor man who was putting everything together , he started of with the Heatmap code , initially he was dablling with Openlayers later we switched to Leaflet which was much easier to code in . Overall at the end of it we produced the following heat map .

heatmap

which was sort of hardcoded and  static one with the limitations of time we could produce here is the code for the  Heatmap .

The experience has been good for everyone since we we were getting together after longtime and produced something in the end. Scope for improvements we can cover more years with  a time line kind of interface and really see it visually which is kind of nice than just some dry numbers on a spread sheet . We dispersed with lots of sweet memories  and hope to have more such events in future.

Tools and Software used

[1] Python
[2]
 Geonames
[
3] Javascript
[4] Heatcanvas
[
5] Leaflet

Fork from Fossacademy

have done some clean up to the base code , now on we will be working on source from this tree
Fossacademy Source feel free to fork.

Setting up the Dev environment and working on the Fork

Khanacademy.org code is lying here Source , the link from here will point us to the Source Link i have checked and tried getting kinhg account looks like it a paid site and we need to pay after 45 days , my initial though before visiting this site was to branch and maintain a tree there itself looks like it is not as open as it claims. So the other option is to fork since the code is anyway licensed under BSD2 lincense .

We are going to maintain two Repos one of Khanacademy ( KA) and one of Fossacademy (FA) .

why maintain KA code , because initially when we start off as FA we will have just KA code but over time it is going to differ and change in ways , but also we will have some changes upstream in KA which we will be needing from time to time to fix bugs which must have already crept in.

yes it is a overhead we have to live with for the time being .

coming back to the FA we will be maintaining the code on Bitbucket , and everyone will pull from the stable FA and start maintaining the FA trunkc or fork they will be free to take the call .

on maintaining the dev environment , i found any variant of Eclipse to be a good IDE to maintain the code , you are free to maintain any IDE/Editor you are comfortable with .

this video explains it all Setting Dev environment using eclipse .

i will be writing on the goals and specs for the project as we move along keep watching this space …

PYTHONSTARTUP == .profile

When you use Python interactively, it is frequently handy to have some standard commands executed every time the interpreter is started. You can do this by setting an environment variable named PYTHONSTARTUP to the name of a file containing your start-up commands. This is similar to the .profile feature of the Unix shells.

This file is only read in interactive sessions, not when Python reads commands from a script, and not when /dev/tty is given as the explicit source of commands (which otherwise behaves like an interactive session). It is executed in the same namespace where interactive commands are executed, so that objects that it defines or imports can be used without qualification in the interactive session. You can also change the prompts sys.ps1 and sys.ps2 in this file.

If you want to read an additional start-up file from the current directory, you can program this in the global start-up file using code like if os.path.isfile(‘.pythonrc.py’): execfile(‘.pythonrc.py’). If you want to use the startup file in a script, you must do this explicitly in the script:

import os
filename = os.environ.get(‘PYTHONSTARTUP’)
if filename and os.path.isfile(filename):
execfile(filename)