# install.py

def main():
    print('install.py')
    print('Script (empty for now) to setup local data')
    print('folders, connections to databases, etc.\n')

    print('[TODO] Setup Local folder structure...')

    print('[TODO] Link to databases...')


    print('Done')
 
main()
@@ -7,16 +7,215 @@
 all.py%0A%0A
+import os%0Aimport sys%0A%0Adata_fldr = os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + os.sep + '..' + os.sep +  'rawdata' + os.sep + 'data' ) %0A%0Andx_file = data_fldr + os.sep + '_index.ndx'%0A%0A
 def main
@@ -263,24 +263,8 @@
 ript
- (empty for now)
  to 
@@ -399,65 +399,1418 @@
     
-print('%5BTODO%5D Link to databases...')%0A%0A%0A    print('Done')%0A
+rebuild_index()%0A%0A    print('Done')%0A%0A%0A%0Adef rebuild_index():%0A    %22%22%22%0A    scans rawdata%5Cdata%5C folders to create lookups%0A    of all tables, column names%0A    %22%22%22%0A    print('Building indexes...')%0A    print(data_fldr)%0A    ndx = %5B%5D%0A    for root, _, files in os.walk(data_fldr):%0A        for f in files:%0A            if f%5B-3:%5D.upper() in %5B'CSV','TXT'%5D:%0A                ndx.extend(get_index_terms(root + os.sep + f, f))%0A    with open(ndx_file, 'w') as fio:%0A        for i in ndx:%0A            fio.write(i + '%5Cn')%0A    %0Adef get_index_terms(fname, shortname):%0A    %22%22%22%0A    reads the file 'fname' and returns all index values%0A    for it in terms of fname.col_name, e.g.%0A    finance_transactions.transaction_type%0A    %22%22%22%0A    data_files = %5B%5D%0A    terms = %5B%5D%0A    folder_names = fname.split(os.sep)%0A    start = False%0A    root_name = ''%0A    for num, fldr in enumerate(folder_names):%0A        if start == True:%0A            root_name += fldr + '.'%0A        if fldr == 'data':%0A            start = True%0A    #print('fname = ', fname, ' root_name = ', root_name)    %0A    root_name = root_name%5B:-5%5D%0A    #terms.append(root_name)%0A    data_files.append(root_name)%0A    %0A    #read the file and add column names to list of terms%0A    with open(fname, 'r') as f:%0A        hdr = f.readline()%0A        cols = hdr.split(',')%0A        for col in cols:%0A            terms.append(root_name + '.' + col.strip(' ').strip('%22').strip('%5Cn'))%0A    %0A    return terms%0A   
  %0Ama

install script rebuilds list of all columns in csv files in \data