import pandas as pd
import cx_Oracle
db=cx_Oracle.connect(‘username/password@ORCL’)
cr=db.cursor()
df = pd.read_excel(r’G:\xxx\xxx.xls’, sheetname=0)
dict_country = df.set_index(‘xx’).T.to_dict(‘list’)
for i in [15, 16, 17]:
str_ = (“G:\xxx\xxx03%d.txt”%i)
with open(str_, “w”) as file:
for item in dict_country:
sql = (“select count(distinct(substr(列1, 19, 6))) from xxxx%d where 列2 = ‘%d’” % (i, item))
cr.execute(sql)
df_raw=cr.fetchall()
file.write("%d/n" % df_raw[0][0])
file.close()