I have excel file with 2 tabs. First tab is "Summary" and 2nd tab is "Employee". The format of excel looks like below. Please note that below excel is for showcase only my original file contains ALWAYS "Summary" as 1st sheet and other tabs are ALWAYS based on "Sheet Name" (cell B2). So an excel can have 10 tabs or 20 tabs with 1st one being "Summary", which we do not need.What I would like to do is extract data from 6th row on-wards from each sheet and create txt file which looks like below in "Output in TXT file" section.So the generated employee txtfile will have 2 SQL code which looks like below. If type is "STRING" then type will be replace with VARCHAR, if type is date then replace with date and so on in generated txt file.
I started working on loading the file in Python using this link However, whenever I run below code for txt file generation I am receiving 4 different txt files with the file names from row 6 to 9. Not sure what is the issue? Basically, I need one txt file with below snippet "Output in TXT file". Please help!!
Thanks in advance for your time and efforts!!
Excel file format
Output in TXT file:
Code so far
from openpyxl import load_workbook
data_file='\test.xlsx'
# Load the entire workbook.
wb = load_workbook(data_file)
ws = wb['Employee']
for i in range(6, ws.max_row+1):
name = ws.cell(row=i, column=1).value
outputFile = open('C:/Jupyter Notebook/{}.txt'.format(name), 'w')
for j in range(1, ws.max_column + 1):
outputFile.write(ws.cell(row=i, column=j).value + '\n')
outputFile.close()

