Beispiel #1
0
def write_new_holters(folders, output):
    '''
    Finds holters in given folders with subfolders. Checks does this holters exist in output file,
    if doesn`t reads data from holters and saves it in output file.
    If there are any error pathes saves them into error_holters.txt
    '''
    existing_holters = _get_existing_holters(output) if os.path.exists(output) else []
    newholter_pathes = []
    for pathes in [_get_all_holters_in_folder(folder) for folder in folders]:
        newholter_pathes += [path for path in pathes if not os.path.split(path)[1] in existing_holters]
    print 'naydeno', len(newholter_pathes), 'unikalnih holterov'

    holters, error_holters = [], []
    if len(newholter_pathes):
        print 'schitivayu holtera:'
    for path, i in zip(newholter_pathes, range(len(newholter_pathes))):
        print 'holter (', i + 1, ':', len(newholter_pathes), ')'
        try:
            holters.append(HolterWrapper.load_holter(path.encode('utf-8')))
        except:
            print 'error in holter', path.encode('utf-8')
            error_holters.append(path.encode('utf-8'))
    if holters:
        print 'Sohranyaem v', output
        write_holters(holters, output)
    if error_holters:
        f = open('error_holters.txt', 'wb')
        f.write(str(error_holters))
        f.close()
Beispiel #2
0
    write_row = len(sheet.col_values(2))
    for holter in holters:
        _write_holter(csheet, write_row, holter)
        write_row += 1

    del wb
    copied_wb.save(HOLTERSFILE)
    

if __name__ == '__main__':
    # search_path = str(import_pathes())
    search_path = r'\\MYBOOKLIVE\Public\2012\*\*\*.ZHR'
    print 'smotrim holtera v papke:', search_path
    pathes = glob.glob(search_path)
    existing_holters = get_existing_holters()
    newholter_pathes = [path for path in pathes if not os.path.split(path)[1] in existing_holters]
    print 'naydeno', len(newholter_pathes), 'unikalnih holterov'

    holters = []
    if len(newholter_pathes): print 'schitivayu holtera:'
    for path, i in zip(newholter_pathes, range(len(newholter_pathes))):
        print 'holter (', i+1 ,':', len(newholter_pathes), ')', path
        holters.append(HolterWrapper.load_holter(path))


    if holters: 
        print 'Sohranyaem v', HOLTERSFILE
        write_holters(holters)

    raw_input('Programa zavershila rabotu, nashmite lyubuyu knopku')