get Excel

class readXls():

def read(self, name, sheetname):
try:
print('start read excel !')
self.path = os.path.abspath(os.path.join(os.path.dirname(__file__), name))
table = xlrd.open_workbook(self.path).sheet_by_name(sheetname)
xldata = []
for i in tqdm(range(1, table.nrows)):
xldata.append(table.row_values(i))
return xldata
except Exception as e:
raise e


def getsql(excelname, sheetname, filename):
if os.path.exists(filename):
os.system('type nul>{}'.format(filename))
sql_path = os.path.abspath(os.path.join(os.path.dirname(__file__), filename))
xls = readXls()
data = xls.read(excelname, sheetname)
print('\nstart write sql !')
with open(sql_path, 'a', encoding='utf-8') as f:
for i in tqdm(data):
postcode, teamcode, countrycode, = i
if isinstance(teamcode, str):
上一篇:python处理word和excel文件


下一篇:【无标题】MTBF是什么意思?交换机做MTBF有什么要求?MTTF、MTBF和MTTR的区别是什么?