Reputation: 135
I am new to python and trying to write some code using Excel and 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:
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.
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---')
Upvotes: 0
Views: 2270
Reputation: 455
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.
Upvotes: 2
Reputation: 537
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.
But neither I believe using openpyxl library is right way to learn python, nor I believe you are doing it for learning.
Upvotes: 0