def csv_from_excel():
    fname = '../case_test.xls'
    rcDict = getExcelData2.getFileData(fname)
    sheets = rcDict.keys()
    sheets.sort()
    sheet_one_titles = {} 
    sheet_one_table = {}
    sheet_one_page = {}
    sheet_two_titles = {}
    sheet_two_table = {}
    sheet_two_page = {}
    i = 1;
    for sheet in sheets:
        category_key = 0
        sheetdata = rcDict[sheet]
	nrows = sheetdata['nrows']
	ncols = sheetdata['ncols']
	sheet_name = sheetdata['sheet_name']
	cell_dict = sheetdata['cell_dict']
        lst_category = ["Summaries_data","Sectors_data","Instruments_data","Balance_Sheet_and_Changes_in_Net_Worth_data","Supplementary_Tables_data","Integrated_Macroeconomic_Accounts_for_the_United_States_data"]
        for row in range(3, nrows):
            #print "==========================================="
	    rowwiseData = []
            for col in range(0, ncols):
            #for col in range(1, 4):
                data = cell_dict.get((row, col), None)
		if data:
                   dt = data.get('data', None)
                   try:
                        dt = dt.strip()
                   except:
                        pass
  		   if dt:
                        try:
 	                   dt = str(dt)
                           dt = convert(dt)
                        except:
                           pass
                   rowwiseData.append(dt.encode('ascii', 'xmlcharrefreplace'))
            category = 1
            for key in range(2,len(rowwiseData)):
                #print 'element >>>',rowwiseData[key],"key>>",key
                if rowwiseData[key]:
                    category = 0
                    break
            if category == 1 and i == 1:
                sheet_one_titles[lst_category[category_key]] = []
                sheet_one_table[lst_category[category_key]] = []
                sheet_one_page[lst_category[category_key]] = [] 
                category_key += 1;
            elif category == 1 and i == 2:
                sheet_two_titles[lst_category[category_key]] = []
                sheet_two_table[lst_category[category_key]] = []
                sheet_two_page[lst_category[category_key]] = []
                category_key += 1;
            #print 'category key>>',category_key
            #print 'category >>',category
            if i == 1:
	        sheet_one_titles[lst_category[category_key-1]].append(rowwiseData[1])
                sheet_one_titles[rowwiseData[1]] = []
                sheet_one_titles[rowwiseData[1]].append(rowwiseData)
                for key in range(2,len(rowwiseData)):
                    if rowwiseData[key] and key%2 == 0:
                        sheet_one_table[lst_category[category_key-1]].append(rowwiseData[key])
                        sheet_one_table[rowwiseData[key]] = []
                        sheet_one_table[rowwiseData[key]].append(rowwiseData)
                    elif rowwiseData[key] and key%2 != 0:
	                sheet_one_page[lst_category[category_key-1]].append(rowwiseData[key])
                        sheet_one_page[rowwiseData[key]] = []
                        sheet_one_page[rowwiseData[key]].append(rowwiseData)
            else:
                sheet_two_titles[lst_category[category_key-1]].append(rowwiseData[1])
                sheet_two_titles[rowwiseData[1]] = []
                sheet_two_titles[rowwiseData[1]].append(rowwiseData)
                for key in range(2,len(rowwiseData)):
                    if rowwiseData[key] and key%2 == 0:
                        sheet_two_table[lst_category[category_key-1]].append(rowwiseData[key])
                        sheet_two_table[rowwiseData[key]] = []
                        sheet_two_table[rowwiseData[key]].append(rowwiseData)
                    elif rowwiseData[key] and key%2 != 0:
                        sheet_two_page[lst_category[category_key-1]].append(rowwiseData[key])
                        sheet_two_page[rowwiseData[key]] = []
                        sheet_two_page[rowwiseData[key]].append(rowwiseData)
        i += 1
            #print rowwiseData
    #print "+++++++++++++++++++++++++++++++++++++++"
    #print sheet_one_titles
    #print "+++++++++++++++++++++++++++++++++++++++"
    #print sheet_two_titles
    #print "+++++++++++++++++++++++++++++++++++++++"
    #print sheet_one_table
    #print "+++++++++++++++++++++++++++++++++++++++"
    #print sheet_two_table
    #print "++++++++++++++++++++++++++++++++++++++++"
    #print sheet_one_page
    #print "+++++++++++++++++++++++++++++++++++++++"
    #print sheet_two_page
    new_tbl = {}
    old_tbl = {}
    new_pg = {}
    old_pg = {}
    new_title = {}
    old_title = {}
    for keys in lst_category:
        new_tbl[keys] = []
        old_tbl[keys] = []
        new_pg[keys] = []
        old_pg[keys] = []
        new_title[keys] = []
        old_title[keys] = []
        new_tbl_lst = sheet_two_table[keys]
        old_tbl_lst = sheet_one_table[keys]
        new_tbl[keys] = list(set(new_tbl_lst) - set(old_tbl_lst))
        old_tbl[keys] = list(set(old_tbl_lst) - set(new_tbl_lst))
        new_pg_lst = sheet_two_page[keys]
        old_pg_lst = sheet_one_page[keys]
        new_pg[keys] = list(set(new_pg_lst) - set(old_pg_lst))
        old_pg[keys] = list(set(old_pg_lst) - set(new_pg_lst))
        new_tit_lst = sheet_two_titles[keys]
        old_tit_lst = sheet_one_titles[keys]
        new_title[keys] = list(set(new_tit_lst) - set(old_tit_lst))
        old_title[keys] = list(set(old_tit_lst) - set(new_tit_lst))
    print "======================================="
    print new_tbl
    print "======================================="
    print new_pg
    print "======================================="
    print new_title
    print "======================================="
    print old_tbl
    print "======================================="
    print old_pg
    print "======================================="
    print old_title
    print "======================================="
    print sheet_two_titles['Federal Government Employee Retirement Funds: Defined Contribution Plans']
    print sheet_one_titles['State and Local Government Employee Retirement Funds: Defined Benefit Plans']
    return 'Done';
    def read_from_excel(self):
        fname = '../case_test.xls'
        rcDict = getExcelData2.getFileData(fname)
        sheets = rcDict.keys()
        sheets.sort()
        category = {}
        main_table = {}
        sheets_name = []
        for sheet in sheets:
            sheetdata = rcDict[sheet]
            nrows = sheetdata['nrows']
            ncols = sheetdata['ncols']
            sheet_name = sheetdata['sheet_name']
            sheets_name.append(sheet_name)
            category[sheet_name] = {}
            main_table[sheet_name] = []
            cell_dict = sheetdata['cell_dict']
            count = 0
            for row in range(3, nrows):
                rowwiseData = []
                for col in range(0, ncols):
                    data = cell_dict.get((row, col), None)
                    if data:
                        dt = data.get('data', None)
                        try:
                            dt = dt.strip()
                        except:
                            pass
                        if dt:
                            try:
                                dt = str(dt)
                                dt = convert(dt)
                            except:
                                pass
                        rowwiseData.append(
                            dt.encode('ascii', 'xmlcharrefreplace'))
                category_chk = 1
                for key in range(2, len(rowwiseData)):
                    if rowwiseData[key]:
                        category_chk = 0
                        break
                if category_chk == 1:
                    #category[sheet_name].append(rowwiseData[1])
                    category_index = rowwiseData[1]
                    main_table[sheet_name].append(category_index)
                    category[sheet_name][category_index] = []
                    continue
                category[sheet_name][category_index].append(rowwiseData)
            #print category,"</br>",main_table,"</br>",sheets_name
            #print main_table,"</br>",sheets_name
        main_table_per_sheet = []
        for sheet in sheets_name:
            print main_table.get(sheet)
            main_table_per_sheet.append(main_table.get(sheet))
            print len(main_table.get(sheet))
            #for table in main_table.get(sheet):
            #print "==========================================================================="
            #print category[sheet][table]
            #sys.exit()
            #new table added check
        new_table_added = []
        new_table_added = list(
            set(main_table_per_sheet[1]) - set(main_table_per_sheet[0]))
        #print ">>>>",new_table_added

        diff1_lst = []
        diff2_lst = []
        for table in main_table_per_sheet[1]:
            sheet1_data = category['Current_quarter_data'][table]
            sheet2_data = category['Pre_quarter_data'][table]

            #new row added or old row removed check
            no_new_added = len(sheet1_data) - len(sheet2_data)
            no_old_removed = len(sheet2_data) - len(sheet1_data)
            new_rows_added = []
            old_rows_removed = []
            if no_new_added > 0:
                for k in range(
                        len(sheet1_data) - no_new_added, len(sheet1_data)):
                    new_rows_added.append(sheet1_data[k])
            if no_old_removed > 0:
                for l in range(
                        len(sheet2_data) - no_old_removed, len(sheet2_data)):
                    old_rows_removed.append(sheet2_data[l])
            #print new_rows_added
            #print old_rows_removed

            #Each element check
            for i in range(len(sheet1_data)):
                #diff_lst.append([set(sheet1_data[i]) - set(sheet2_data[i])] if len([set(sheet1_data[i]) - set(sheet2_data[i])]))
                '''
		    if len(list(set(sheet1_data[i]) - set(sheet2_data[i]))):
			diff1_lst.append((i,sheet1_data[i],list(set(sheet1_data[i]) - set(sheet2_data[i]))))
		    if len(list(set(sheet2_data[i]) - set(sheet1_data[i]))):
			diff2_lst.append((i,sheet2_data[i],list(set(sheet1_data[i]) - set(sheet2_data[i]))))
		    '''
                for j in range(len(sheet1_data[i])):
                    if (sheet1_data[i][j] != sheet2_data[i][j]):
                        diff1_lst.append(
                            (i, j, sheet1_data[i], sheet1_data[i][j],
                             sheet2_data[i][j]))

        print diff1_lst
        #print diff2_lst

        return 'Done'
def csv_from_excel():
    fname = '../case_test.xls'
    rcDict = getExcelData2.getFileData(fname)
    sheets = rcDict.keys()
    sheets.sort()
    sheet_one_titles = []
    sheet_one_table = []
    sheet_one_page = []
    sheet_two_titles = []
    sheet_two_table = []
    sheet_two_page = []
    i = 1
    for sheet in sheets:
        sheetdata = rcDict[sheet]
        nrows = sheetdata['nrows']
        ncols = sheetdata['ncols']
        sheet_name = sheetdata['sheet_name']
        cell_dict = sheetdata['cell_dict']
        for row in range(3, nrows):
            #print "==========================================="
            rowwiseData = []
            for col in range(0, ncols):
                #for col in range(1, 4):
                data = cell_dict.get((row, col), None)
                if data:
                    dt = data.get('data', None)
                    if dt:
                        try:
                            dt = str(dt)
                            dt = convert(dt)
                        except:
                            pass
                    rowwiseData.append(dt.encode('ascii', 'xmlcharrefreplace'))
            if i == 1:
                sheet_one_titles.append(rowwiseData[1])
                for key in range(2, len(rowwiseData)):
                    if rowwiseData[key] and key % 2 == 0:
                        sheet_one_table.append(rowwiseData[key])
                    elif rowwiseData[key] and key % 2 != 0:
                        sheet_one_page.append(rowwiseData[key])
            else:
                sheet_two_titles.append(rowwiseData[1])
                for key in range(2, len(rowwiseData)):
                    if rowwiseData[key] and key % 2 == 0:
                        sheet_two_table.append(rowwiseData[key])
                    elif rowwiseData[key] and key % 2 != 0:
                        sheet_two_page.append(rowwiseData[key])
        i += 1
        #print rowwiseData
    print "+++++++++++++++++++++++++++++++++++++++"
    print sheet_one_titles
    print "+++++++++++++++++++++++++++++++++++++++"
    print sheet_two_titles
    print "+++++++++++++++++++++++++++++++++++++++"
    print sheet_one_table
    print "+++++++++++++++++++++++++++++++++++++++"
    print sheet_two_table
    print "++++++++++++++++++++++++++++++++++++++++"
    print sheet_one_page
    print "+++++++++++++++++++++++++++++++++++++++"
    print sheet_two_page
    return 'Done'
Exemple #4
0
def csv_from_excel():
    fname = '../case_test.xls'
    rcDict = getExcelData2.getFileData(fname)
    sheets = rcDict.keys()
    sheets.sort()
    sheet_one_titles = {}
    sheet_one_table = {}
    sheet_one_page = {}
    sheet_two_titles = {}
    sheet_two_table = {}
    sheet_two_page = {}
    i = 1
    for sheet in sheets:
        category_key = 0
        sheetdata = rcDict[sheet]
        nrows = sheetdata['nrows']
        ncols = sheetdata['ncols']
        sheet_name = sheetdata['sheet_name']
        cell_dict = sheetdata['cell_dict']
        lst_category = [
            "Summaries_data", "Sectors_data", "Instruments_data",
            "Balance_Sheet_and_Changes_in_Net_Worth_data",
            "Supplementary_Tables_data",
            "Integrated_Macroeconomic_Accounts_for_the_United_States_data"
        ]
        for row in range(3, nrows):
            #print "==========================================="
            rowwiseData = []
            for col in range(0, ncols):
                #for col in range(1, 4):
                data = cell_dict.get((row, col), None)
                if data:
                    dt = data.get('data', None)
                    try:
                        dt = dt.strip()
                    except:
                        pass
                    if dt:
                        try:
                            dt = str(dt)
                            dt = convert(dt)
                        except:
                            pass
                    rowwiseData.append(dt.encode('ascii', 'xmlcharrefreplace'))
            category = 1
            for key in range(2, len(rowwiseData)):
                #print 'element >>>',rowwiseData[key],"key>>",key
                if rowwiseData[key]:
                    category = 0
                    break
            if category == 1 and i == 1:
                sheet_one_titles[lst_category[category_key]] = []
                sheet_one_table[lst_category[category_key]] = []
                sheet_one_page[lst_category[category_key]] = []
                category_key += 1
            elif category == 1 and i == 2:
                sheet_two_titles[lst_category[category_key]] = []
                sheet_two_table[lst_category[category_key]] = []
                sheet_two_page[lst_category[category_key]] = []
                category_key += 1
        #print 'category key>>',category_key
        #print 'category >>',category
            if i == 1:
                sheet_one_titles[lst_category[category_key - 1]].append(
                    rowwiseData[1])
                sheet_one_titles[rowwiseData[1]] = []
                sheet_one_titles[rowwiseData[1]].append(rowwiseData)
                for key in range(2, len(rowwiseData)):
                    if rowwiseData[key] and key % 2 == 0:
                        sheet_one_table[lst_category[category_key - 1]].append(
                            rowwiseData[key])
                        sheet_one_table[rowwiseData[key]] = []
                        sheet_one_table[rowwiseData[key]].append(rowwiseData)
                    elif rowwiseData[key] and key % 2 != 0:
                        sheet_one_page[lst_category[category_key - 1]].append(
                            rowwiseData[key])
                        sheet_one_page[rowwiseData[key]] = []
                        sheet_one_page[rowwiseData[key]].append(rowwiseData)
            else:
                sheet_two_titles[lst_category[category_key - 1]].append(
                    rowwiseData[1])
                sheet_two_titles[rowwiseData[1]] = []
                sheet_two_titles[rowwiseData[1]].append(rowwiseData)
                for key in range(2, len(rowwiseData)):
                    if rowwiseData[key] and key % 2 == 0:
                        sheet_two_table[lst_category[category_key - 1]].append(
                            rowwiseData[key])
                        sheet_two_table[rowwiseData[key]] = []
                        sheet_two_table[rowwiseData[key]].append(rowwiseData)
                    elif rowwiseData[key] and key % 2 != 0:
                        sheet_two_page[lst_category[category_key - 1]].append(
                            rowwiseData[key])
                        sheet_two_page[rowwiseData[key]] = []
                        sheet_two_page[rowwiseData[key]].append(rowwiseData)
        i += 1
        #print rowwiseData
    #print "+++++++++++++++++++++++++++++++++++++++"
    #print sheet_one_titles
    #print "+++++++++++++++++++++++++++++++++++++++"
    #print sheet_two_titles
    #print "+++++++++++++++++++++++++++++++++++++++"
    #print sheet_one_table
    #print "+++++++++++++++++++++++++++++++++++++++"
    #print sheet_two_table
    #print "++++++++++++++++++++++++++++++++++++++++"
    #print sheet_one_page
    #print "+++++++++++++++++++++++++++++++++++++++"
    #print sheet_two_page
    new_tbl = {}
    old_tbl = {}
    new_pg = {}
    old_pg = {}
    new_title = {}
    old_title = {}
    for keys in lst_category:
        new_tbl[keys] = []
        old_tbl[keys] = []
        new_pg[keys] = []
        old_pg[keys] = []
        new_title[keys] = []
        old_title[keys] = []
        new_tbl_lst = sheet_two_table[keys]
        old_tbl_lst = sheet_one_table[keys]
        new_tbl[keys] = list(set(new_tbl_lst) - set(old_tbl_lst))
        old_tbl[keys] = list(set(old_tbl_lst) - set(new_tbl_lst))
        new_pg_lst = sheet_two_page[keys]
        old_pg_lst = sheet_one_page[keys]
        new_pg[keys] = list(set(new_pg_lst) - set(old_pg_lst))
        old_pg[keys] = list(set(old_pg_lst) - set(new_pg_lst))
        new_tit_lst = sheet_two_titles[keys]
        old_tit_lst = sheet_one_titles[keys]
        new_title[keys] = list(set(new_tit_lst) - set(old_tit_lst))
        old_title[keys] = list(set(old_tit_lst) - set(new_tit_lst))
    print "======================================="
    print new_tbl
    print "======================================="
    print new_pg
    print "======================================="
    print new_title
    print "======================================="
    print old_tbl
    print "======================================="
    print old_pg
    print "======================================="
    print old_title
    print "======================================="
    print sheet_two_titles[
        'Federal Government Employee Retirement Funds: Defined Contribution Plans']
    print sheet_one_titles[
        'State and Local Government Employee Retirement Funds: Defined Benefit Plans']
    return 'Done'
def read_from_excel():
    fname = '../case_test.xls'
    rcDict = getExcelData2.getFileData(fname)
    sheets = rcDict.keys()
    sheets.sort()
    sheet_one_titles = {} 
    sheet_one_table = {}
    sheet_one_page = {}
    sheet_two_titles = {}
    sheet_two_table = {}
    sheet_two_page = {}
    i = 1;
    for sheet in sheets:
        category_key = 0
        sheetdata = rcDict[sheet]
	nrows = sheetdata['nrows']
	ncols = sheetdata['ncols']
	sheet_name = sheetdata['sheet_name']
	cell_dict = sheetdata['cell_dict']
        #lst_category = ["Summaries_data","Sectors_data","Instruments_data","Balance_Sheet_and_Changes_in_Net_Worth_data","Supplementary_Tables_data","Integrated_Macroeconomic_Accounts_for_the_United_States_data"]
        for row in range(3, nrows):
            #print "==========================================="
	    rowwiseData = []
            for col in range(0, ncols):
            #for col in range(1, 4):
                data = cell_dict.get((row, col), None)
		if data:
                   dt = data.get('data', None)
                   try:
                        dt = dt.strip()
                   except:
                        pass
  		   if dt:
                        try:
 	                   dt = str(dt)
                           dt = convert(dt)
                        except:
                           pass
                   rowwiseData.append(dt.encode('ascii', 'xmlcharrefreplace'))
            category = 1
            for key in range(2,len(rowwiseData)):
                if rowwiseData[key]:
                    category = 0
                    break
            if category == 1 and i == 1:
                sheet_one_titles[lst_category[category_key]] = []
                sheet_one_table[lst_category[category_key]] = []
                sheet_one_page[lst_category[category_key]] = [] 
                category_key += 1;
            elif category == 1 and i == 2:
                sheet_two_titles[lst_category[category_key]] = []
                sheet_two_table[lst_category[category_key]] = []
                sheet_two_page[lst_category[category_key]] = []
                category_key += 1;
            if i == 1:
	        sheet_one_titles[lst_category[category_key-1]].append(rowwiseData[1])
                sheet_one_titles[rowwiseData[1]] = []
                sheet_one_titles[rowwiseData[1]].append(rowwiseData)
                for key in range(2,len(rowwiseData)):
                    if rowwiseData[key] and key%2 == 0:
                        sheet_one_table[lst_category[category_key-1]].append(rowwiseData[key])
                        sheet_one_table[rowwiseData[key]] = []
                        sheet_one_table[rowwiseData[key]].append(rowwiseData)
                    elif rowwiseData[key] and key%2 != 0:
	                sheet_one_page[lst_category[category_key-1]].append(rowwiseData[key])
                        sheet_one_page[rowwiseData[key]] = []
                        sheet_one_page[rowwiseData[key]].append(rowwiseData)
            else:
                sheet_two_titles[lst_category[category_key-1]].append(rowwiseData[1])
                sheet_two_titles[rowwiseData[1]] = []
                sheet_two_titles[rowwiseData[1]].append(rowwiseData)
                for key in range(2,len(rowwiseData)):
                    if rowwiseData[key] and key%2 == 0:
                        sheet_two_table[lst_category[category_key-1]].append(rowwiseData[key])
                        sheet_two_table[rowwiseData[key]] = []
                        sheet_two_table[rowwiseData[key]].append(rowwiseData)
                    elif rowwiseData[key] and key%2 != 0:
                        sheet_two_page[lst_category[category_key-1]].append(rowwiseData[key])
                        sheet_two_page[rowwiseData[key]] = []
                        sheet_two_page[rowwiseData[key]].append(rowwiseData)
        i += 1
    new_tbl = {}
    old_tbl = {}
    new_pg = {}
    old_pg = {}
    new_title = {}
    old_title = {}
    for keys in lst_category:
        new_tbl[keys] = []
        old_tbl[keys] = []
        new_pg[keys] = []
        old_pg[keys] = []
        new_title[keys] = []
        old_title[keys] = []
        new_tbl_lst = sheet_two_table[keys]
        old_tbl_lst = sheet_one_table[keys]
        new_tbl[keys] = list(set(new_tbl_lst) - set(old_tbl_lst))
        old_tbl[keys] = list(set(old_tbl_lst) - set(new_tbl_lst))
        new_pg_lst = sheet_two_page[keys]
        old_pg_lst = sheet_one_page[keys]
        new_pg[keys] = list(set(new_pg_lst) - set(old_pg_lst))
        old_pg[keys] = list(set(old_pg_lst) - set(new_pg_lst))
        new_tit_lst = sheet_two_titles[keys]
        old_tit_lst = sheet_one_titles[keys]
        new_title[keys] = list(set(new_tit_lst) - set(old_tit_lst))
        old_title[keys] = list(set(old_tit_lst) - set(new_tit_lst))
    workbook = xlwt.Workbook()
    save_excel(workbook, new_title,sheet_two_titles,'New_FED_Descriptions')
    save_excel(workbook, old_title,sheet_one_titles,'Old_FED_Descriptions')
    save_excel(workbook, old_pg,sheet_one_page,'Old_Pages')
    workbook.save('/var/www/html/Lexis_Link_Monitoring/output/diff_result.xlsx')

    return 'Done';
Exemple #6
0
def read_from_excel():
    fname = '../case_test.xls'
    rcDict = getExcelData2.getFileData(fname)
    sheets = rcDict.keys()
    sheets.sort()
    sheet_one_titles = {}
    sheet_one_table = {}
    sheet_one_page = {}
    sheet_two_titles = {}
    sheet_two_table = {}
    sheet_two_page = {}
    i = 1
    for sheet in sheets:
        category_key = 0
        sheetdata = rcDict[sheet]
        nrows = sheetdata['nrows']
        ncols = sheetdata['ncols']
        sheet_name = sheetdata['sheet_name']
        cell_dict = sheetdata['cell_dict']
        #lst_category = ["Summaries_data","Sectors_data","Instruments_data","Balance_Sheet_and_Changes_in_Net_Worth_data","Supplementary_Tables_data","Integrated_Macroeconomic_Accounts_for_the_United_States_data"]
        for row in range(3, nrows):
            #print "==========================================="
            rowwiseData = []
            for col in range(0, ncols):
                #for col in range(1, 4):
                data = cell_dict.get((row, col), None)
                if data:
                    dt = data.get('data', None)
                    try:
                        dt = dt.strip()
                    except:
                        pass
                    if dt:
                        try:
                            dt = str(dt)
                            dt = convert(dt)
                        except:
                            pass
                    rowwiseData.append(dt.encode('ascii', 'xmlcharrefreplace'))
            category = 1
            for key in range(2, len(rowwiseData)):
                if rowwiseData[key]:
                    category = 0
                    break
            if category == 1 and i == 1:
                sheet_one_titles[lst_category[category_key]] = []
                sheet_one_table[lst_category[category_key]] = []
                sheet_one_page[lst_category[category_key]] = []
                category_key += 1
            elif category == 1 and i == 2:
                sheet_two_titles[lst_category[category_key]] = []
                sheet_two_table[lst_category[category_key]] = []
                sheet_two_page[lst_category[category_key]] = []
                category_key += 1
            if i == 1:
                sheet_one_titles[lst_category[category_key - 1]].append(
                    rowwiseData[1])
                sheet_one_titles[rowwiseData[1]] = []
                sheet_one_titles[rowwiseData[1]].append(rowwiseData)
                for key in range(2, len(rowwiseData)):
                    if rowwiseData[key] and key % 2 == 0:
                        sheet_one_table[lst_category[category_key - 1]].append(
                            rowwiseData[key])
                        sheet_one_table[rowwiseData[key]] = []
                        sheet_one_table[rowwiseData[key]].append(rowwiseData)
                    elif rowwiseData[key] and key % 2 != 0:
                        sheet_one_page[lst_category[category_key - 1]].append(
                            rowwiseData[key])
                        sheet_one_page[rowwiseData[key]] = []
                        sheet_one_page[rowwiseData[key]].append(rowwiseData)
            else:
                sheet_two_titles[lst_category[category_key - 1]].append(
                    rowwiseData[1])
                sheet_two_titles[rowwiseData[1]] = []
                sheet_two_titles[rowwiseData[1]].append(rowwiseData)
                for key in range(2, len(rowwiseData)):
                    if rowwiseData[key] and key % 2 == 0:
                        sheet_two_table[lst_category[category_key - 1]].append(
                            rowwiseData[key])
                        sheet_two_table[rowwiseData[key]] = []
                        sheet_two_table[rowwiseData[key]].append(rowwiseData)
                    elif rowwiseData[key] and key % 2 != 0:
                        sheet_two_page[lst_category[category_key - 1]].append(
                            rowwiseData[key])
                        sheet_two_page[rowwiseData[key]] = []
                        sheet_two_page[rowwiseData[key]].append(rowwiseData)
        i += 1
    new_tbl = {}
    old_tbl = {}
    new_pg = {}
    old_pg = {}
    new_title = {}
    old_title = {}
    for keys in lst_category:
        new_tbl[keys] = []
        old_tbl[keys] = []
        new_pg[keys] = []
        old_pg[keys] = []
        new_title[keys] = []
        old_title[keys] = []
        new_tbl_lst = sheet_two_table[keys]
        old_tbl_lst = sheet_one_table[keys]
        new_tbl[keys] = list(set(new_tbl_lst) - set(old_tbl_lst))
        old_tbl[keys] = list(set(old_tbl_lst) - set(new_tbl_lst))
        new_pg_lst = sheet_two_page[keys]
        old_pg_lst = sheet_one_page[keys]
        new_pg[keys] = list(set(new_pg_lst) - set(old_pg_lst))
        old_pg[keys] = list(set(old_pg_lst) - set(new_pg_lst))
        new_tit_lst = sheet_two_titles[keys]
        old_tit_lst = sheet_one_titles[keys]
        new_title[keys] = list(set(new_tit_lst) - set(old_tit_lst))
        old_title[keys] = list(set(old_tit_lst) - set(new_tit_lst))
    workbook = xlwt.Workbook()
    save_excel(workbook, new_title, sheet_two_titles, 'New_FED_Descriptions')
    save_excel(workbook, old_title, sheet_one_titles, 'Old_FED_Descriptions')
    save_excel(workbook, old_pg, sheet_one_page, 'Old_Pages')
    workbook.save(
        '/var/www/html/Lexis_Link_Monitoring/output/diff_result.xlsx')

    return 'Done'