def importConnFromExcel(fileName, sheetName):
    """ Import connectivity rules from Excel sheet"""
    import openpyxl as xl
    colPreTags = 0
    colPostTags = 1
    colConnFunc = 2
    colSyn = 3
    colProb = 5
    colWeight = 6
    colAnnot = 8
    outFileName = fileName[:-5] + '_' + sheetName + '.py'
    connText = """## Generated using importConnFromExcel() function in params/utils.py 

netParams['connParams'] = [] 

"""
    wb = xl.load_workbook(fileName)
    sheet = wb.get_sheet_by_name(sheetName)
    numRows = sheet.get_highest_row()
    with open(outFileName, 'w') as f:
        f.write(connText)
        for row in range(1, numRows + 1):
            if sheet.cell(row=row, column=colProb).value:
                print('Creating conn rule for row ' + str(row))
                pre = sheet.cell(row=row, column=colPreTags).value
                post = sheet.cell(row=row, column=colPostTags).value
                func = sheet.cell(row=row, column=colConnFunc).value
                syn = sheet.cell(row=row, column=colSyn).value
                prob = sheet.cell(row=row, column=colProb).value
                weight = sheet.cell(row=row, column=colWeight).value
                line = "netParams['connParams'].append({'preConds': {"
                for i, cond in enumerate(pre.split(';')):
                    if i > 0:
                        line = line + ', '
                    cond2 = cond.split('=')
                    line = line + "'" + cond2[0].replace(' ', ''
                        ) + "': " + cond2[1].replace(' ', '')
                line = line + '}'
                line = line + ",\n'postConds': {"
                for i, cond in enumerate(post.split(';')):
                    if i > 0:
                        line = line + ', '
                    cond2 = cond.split('=')
                    line = line + "'" + cond2[0].replace(' ', ''
                        ) + "': " + cond2[1].replace(' ', '')
                line = line + '}'
                line = line + ",\n'connFunc': '" + func + "'"
                line = line + ",\n'synMech': '" + syn + "'"
                line = line + ",\n'probability': " + str(prob)
                line = line + ",\n'weight': " + str(weight)
                line = line + '})'
                line = line + '\n\n'
                f.write(line)
