我的 mac 桌面上有一个 xls 文件,它有很多行(每行由一个单词组成)。我想要的是在终端中每行显示 3 分钟。
请注意,xls 的版本是 2016。
感谢 How to get line number in excel sheet using python?
import pandas as pd
import xlrd
# at first I try to know how many rows and how many columns I have
workbook = xlrd.open_workbook('myfile.xls')
for sheet in workbook.sheets():
for row in range(sheet.nrows):
for column in range(sheet.ncols):
print "row::::: ", row
print "column:: ", column
print "value::: ", sheet.cell(row,column).value
# then I read my file in
df = pd.read_excel(path + filename)
然后我知道我可以使用下面的东西
import time
print("something")
time.sleep(5.5) # pause 5.5 seconds
print("something")
但是我不知道如何在没有写打印的情况下做到这一点,非常感谢任何帮助
最佳答案
在 Mac 上以这种方式进行
import time
import pandas as pd
import os
import xlrd
# at first I try to know how many rows and how many columns I have
workbook = xlrd.open_workbook('myfile.xls')
for sheet in workbook.sheets():
for row in range(sheet.nrows):
for column in range(sheet.ncols):
os.system('clear')
print "value::: ", sheet.cell(row,column).value
time.sleep(5.5) # pause 5.5 seconds
关于python - 如何暂停读取 xls 文件的每一行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40674023/