import openpyxl
class MySearchTableName:
def __init__(self, filePath, srchName):
self.__filePath = filePath
self.__srchName = srchName
self.ENG_TABLE_NAME = 3-1
self.JP_TABLE_NAME = 4-1
######################################################################
# テーブル論理名検索
######################################################################
def searchJp(self):
wb = openpyxl.load_workbook(self.__filePath)
ws = wb.worksheets[0]
for row in ws.rows:
if row[self.ENG_TABLE_NAME].value == self.__srchName:
return row[self.JP_TABLE_NAME].value
######################################################################
# テーブル物理名検索
######################################################################
def searchEng(self):
wb = openpyxl.load_workbook(self.__filePath)
ws = wb.worksheets[0]
for row in ws.rows:
if row[self.JP_TABLE_NAME].value == self.__srchName:
return row[self.ENG_TABLE_NAME].value
#############################################################################
import searchTableName
searchFilePath = 'a5m2_TABLES.xlsx'
tableNameList = ['table_a','table_b']
result = []
for tableName in tableNameList:
result.append(searchTableName.MySearchTableName(searchFilePath, tableName).searchEng())
print(result)
댓글 없음:
댓글 쓰기