有没有办法在python中读取excel表 - 当你正在阅读的表实际上是连接到SQL Server的excel表时?
理论上 - 我问你是否可以从数据链接的excel文件转到python pandas数据帧,pd.read_excel()似乎不适用于此。
答案 0 :(得分:0)
来自:Reading an Excel file in python using pandas
>>> xl = pd.ExcelFile("dummydata.xlsx")
>>> xl.sheet_names
[u'Sheet1', u'Sheet2', u'Sheet3']
>>> df = xl.parse("Sheet1")
答案 1 :(得分:0)
为什么不直接从SQL Server导入数据? Excel甚至与此有什么关系???
import pypyodbc
cnxn = pypyodbc.connect("Driver={SQL Server Native Client 11.0};"
"Server=Your_Server_Name;"
"Database=Your_DB_Name;"
"Trusted_Connection=yes;")
cursor = cnxn.cursor()
cursor.execute('SELECT * FROM Customers')
for row in cursor:
print('row = %r' % (row,))