我的桌面上有一个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")
但我无法弄清楚如何在没有书写印刷的情况下做到这一点,非常感谢任何帮助
答案 0 :(得分:2)
在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
答案 1 :(得分:1)
如果我理解正确,你的问题是你想要在终端上显示一段时间,但是当下一个显示时隐藏。您可以针对length
尝试此操作(请参阅早期版本的已接受答案):
undefined
python3
通常适用于Unix,如果它在Mac上不起作用,this answer会有所帮助。