Example #1
0
import csv
import os
import zipfile
import commands
from StringIO import StringIO

from swiss.cache import Cache

# cache_path = os.path.join(os.path.dirname(__file__), './cache')
cache_path = './cache'
cache = Cache(cache_path)

access_db_zip_url = 'http://unstats.un.org/unsd/cr/registry/regdntransfer.asp?f=186'
details_table_name = 'tblTitles_English_COFOG'
db_filename = 'COFOG_english.mdb'
db_filepath = cache.cache_path(db_filename)

def retrieve():
    '''Retrieve remove files into local cache.
    '''
    fp = cache.retrieve(access_db_zip_url)
    zipfo = zipfile.ZipFile(fp)
    # extract is in 2.6
    # zipfo.extract('COFOG_english.mdb', cache.path)
    out = zipfo.read(db_filename)
    open(db_filepath, 'w').write(out)
    assert os.path.exists(db_filepath), '%s does not exist' % db_filepath

def show_schema(): 
    '''Show the COFOG access db schema'''
    # mdb-schema COFOG_english.mdb 
Example #2
0
'''
import csv
import os
import zipfile
import commands
from StringIO import StringIO

from swiss.cache import Cache

cache_path = os.path.join(os.path.dirname(__file__), 'cache')
cache = Cache(cache_path)

access_db_zip_url = 'http://unstats.un.org/unsd/cr/registry/regdntransfer.asp?f=186'
details_table_name = 'tblTitles_English_COFOG'
db_filename = 'COFOG_english.mdb'
db_filepath = cache.cache_path(db_filename)


def retrieve():
    '''Retrieve remove files into local cache.
    '''
    fp = cache.retrieve(access_db_zip_url)
    zipfo = zipfile.ZipFile(fp)
    # extract is in 2.6
    # zipfo.extract('COFOG_english.mdb', cache.path)
    out = zipfo.read(db_filename)
    open(db_filepath, 'w').write(out)
    assert os.path.exists(db_filepath), '%s does not exist' % db_filepath


def show_schema():