[英]I keep getting [omitting some output] when printing Excel column with python
I am new to python and trying to write some code using Excel and python. 我是python的新手,正在尝试使用Excel和python编写一些代码。
I want to print an excel column, I've imported the file but then when I print the column it starts printing but then it stops sometimes and says: 我想打印一个excel列,我已经导入了文件,但是当我打印该列时,它开始打印,但是有时会停止并说:
omitting some output
省略一些输出
However this doesn't happen all the time, sometimes I will run my code and it will print everything and sometimes it says that. 但是,这并非一直都发生,有时我会运行我的代码,并且它将打印所有内容,有时它会说。 I don't know what that means or how to fix it.
我不知道这意味着什么或如何解决。
If it helps the excel file is very big it has about 5500 rows. 如果它有助于excel文件很大,则它大约有5500行。
Here is my code, please help. 这是我的代码,请帮忙。
import openpyxl
# importing the excel file
wb = openpyxl.load_workbook('Example.xlsx')
# getting the first sheet
name = wb.get_sheet_names()
sheet_name = name[0]
# creating the first sheet object
sheet = wb.get_sheet_by_name(sheet_name)
# print every value from column R
for row in sheet.columns[17]:
print(row.value)
print('---END OF COMMENT---')
I don't think it's even an issue with blank cells. 我认为空白单元格甚至都不是问题。 The problem is that you're trying to print all of this to the console, which has a set buffer limit and won't continue printing data over a certain size.
问题是您要尝试将所有这些信息打印到控制台,该控制台具有设置的缓冲区限制,并且不会继续打印超过特定大小的数据。 If you want a full accounting of everything, you need to print to a text file.
如果要对所有内容进行全面核算,则需要打印到文本文件。
if row.value :
print row.value
will solve your problem. 将解决您的问题。 Because there may be empty cell in in column 17 in one of the 5500 rows.
因为在5500行之一的第17列中可能有空单元格。
But neither I believe using openpyxl library is right way to learn python, nor I believe you are doing it for learning. 但是我既不相信使用openpyxl库是学习python的正确方法,也不相信您正在学习它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.