@@ -0,0 +1,842 @@
+#!/usr/bin/python%0A# -*- coding: utf-8 -*-%0A%0A#%0A# get area and population from csv exported from ministry of finance and puclic administration%0A#%0A%0A%0A# system imports%0Aimport sqlite3 as lite%0Aimport csv%0A%0A# bot imports%0Afrom fixies import *%0A%0A# open sqlite connection%0Acon = lite.connect('municipio.sqlite', isolation_level=None)%0Acur = con.cursor()%0A%0A# get population and adrea and density from csv ...%0Awith open('mun_exp.csv', 'rb') as csvfile:%0A%09csvreader = csv.reader(csvfile)%0A%09for row in csvreader:%0A%09%09nr_ins = row%5B4%5D%0A%09%09area = row%5B8%5D.replace(%22,%22, %22.%22)%0A%09%09pop = row%5B9%5D%0A%09%09den = row%5B10%5D%0A%09%09print nr_ins, %22%7C%22, area, %22%7C%22, pop, %22%7C%22, den, %22 =? %22, float(pop)/float(area)%0A# ... and write them to sqlite%0A%09%09cur.execute(u'UPDATE municipio SET population = ' + pop + u', area = ' + area + u' WHERE nr_inscripcion = ' + nr_ins )%0A%09%0A# close sqlite connection%0Acon.close()%0A

add population and area from csv to sqlite