def copy_bip_tables(state_name, bip_dir, connection): dum_set = DummyModule() dum_set.ERSATZPG_CONFIG = dict(settings.ERSATZPG_CONFIG) dum_set.ERSATZPG_CONFIG['tables'] = {} for bt in bip_tables: table_file = os.path.join(bip_dir,state_name.lower(),bt+'.csv') csvr = csv.reader(open(table_file,'r')) head = csvr.next() head = [(head[i],i+1) for i in range(len(head))] table = dict(settings.CANDIDATE_TABLE) table['table'] = '{bt}_import_{state}'.format(bt=bt,state=state_name.lower()) table['columns'] = dict(head) table['filename'] = table_file dum_set.ERSATZPG_CONFIG['tables'].update({table['table']:table}) ersatz.new_process_copies(dum_set, connection)
from ersatzpg.ersatzpg import ersatz from word_pop import dbload_conf import os for l in filter(lambda x: x.endswith('_lite'), os.listdir('word_pop')): print l dbload_conf.POP_LOAD['filename'] = '/home/nat/code/punsearch/word_pop/' + l ersatz.new_process_copies(dbload_conf)
def copy_state(state_name, state, connection): settings.ERSATZPG_CONFIG['tables']['candidates_import'].update({'filename':state,'table':'candidates_import_{0}'.format(state_name.lower())}) ersatz.new_process_copies(settings, connection)
from ersatzpg.ersatzpg import ersatz from word_pop import dbload_conf import os for l in filter(lambda x: x.endswith('_lite'),os.listdir('word_pop')): print l dbload_conf.POP_LOAD['filename'] = '/home/nat/code/punsearch/word_pop/'+l ersatz.new_process_copies(dbload_conf)