import csv
import os


HERE = os.path.dirname(os.path.abspath(__file__))


def load_db():
    with open(os.path.join(HERE, 'The_Haiti_Earthquake_Database.csv')) as f:
        reader = csv.DictReader(f)
        for elt in reader:
            del elt['']
            yield elt


HAITI_DB = list(load_db())



@@ -1,12 +1,37 @@
+# -*- coding: utf-8 -*-%0A%0A
 import csv%0Ai
@@ -39,16 +39,26 @@
 port os%0A
+import re%0A
 %0A%0AHERE =
@@ -103,16 +103,578 @@
 e__))%0A%0A%0A
+def sexa_to_dec(dh, min, secs, sign):%0A    return sign*(dh + float(min)/60 + float(secs)/60**2)%0A%0A%0Adef string_to_dec(s, neg):%0A    parsed = filter(%0A        None, re.split('%5B%5C'%22 %C2%B0%5D', unicode(s, 'utf-8')))%0A    sign = -1 if parsed%5B-1%5D == neg else 1%0A    return sexa_to_dec(float(parsed%5B0%5D), float(parsed%5B1%5D), float(parsed%5B2%5D),%0A                       sign)%0A%0A%0Adef process_geo_coordinates(obj):%0A    if obj%5B'Latitude'%5D:%0A        obj%5B'Latitude'%5D = string_to_dec(obj%5B'Latitude'%5D, 'S')%0A    if obj%5B'Longitude'%5D:%0A        obj%5B'Longitude'%5D = string_to_dec(obj%5B'Longitude'%5D, 'W')%0A%0A%0A
 def load
@@ -819,16 +819,16 @@
 reader:%0A
-
         
@@ -843,16 +843,57 @@
 elt%5B''%5D%0A
+            process_geo_coordinates(elt)%0A
         

Return geo coordinates in decimal