import pandas as pd
def deleteColumns(sheet):
column_names = ["Organization", "Country Code", "Country Name", "Company Code", "AR Unit", "DSO Unit",
"Market Name", "GEO Name", "AR Type", "AR Category", "Enterprise Number", "Global Buying Group Id",
"Global Buying Group Name", "Customer Number", "Customer Name", "Credit Rating",
"Credit Rating Date", "Sector Name", "Cluster Name", "Cluster Leader", "Legal Contract Number",
"Purchase Order Number", "Coverage Id", "Coverage Type", "External Factoring Flag",
"Pre Payment Flag", "Collection Unit Code", "Invoice Number", "Sequence Number",
"Invoice Line Number", "Item Type", "Entry Date", "Invoice Date", "Due Date", "SOR Invoice Status",
"Division Code", "Revenue Type", "Unit Code", "Sub Unit Code", "Payment Terms",
"Manual Adjustment Flag", "Original Currency Code", "Tax Amount Original", "Balance Amount USD",
"Balance Amount Original", "Balance Amount Local", "Balance Amount Plan USD", "Month End Date",
"Quarter End Date", "Month Close", "Quarter Close", "Month End Aging Description",
"Quarter End Aging Description", "Real Due Date", "Days Outstanding", "Real Aging",
"Last Estimated Forecast Date", "Is Disputed", "Last Dispute Start Date", "Last Dispute End Date",
"Internal Contract Number", "Project Number", "Project Manager Email", "Project Manager Name",
"Last Remark Date", "Collector Name", "Last Remark", "Onshore/Offshore"]
j = 0
while (j < 67):
column = sheet.columns[j]
if column != column_names[j]:
sheet.drop(column, axis=1, inplace=True)
else:
j += 1
sheet.rename( columns={ sheet.columns[68]: "Concatenate"}, inplace=True)
sheet.insert(69, "Accounts group", "")
sheet.iloc[:, 1].replace(to_replace=756,value=755,inplace=True)
sheet['Concatenate'] = sheet['Country Code'].astype(str) + '-' + sheet['Customer Number'].astype(str)
sheet.to_excel("Report_exported.xlsx", engine='xlsxwriter', index=False)
file = pd.ExcelFile('report.xlsx')
sheet = file.parse(0)
deleteColumns(sheet)
print(sheet)