简体   繁体   English

使用python打印Excel列时,我不断得到[省略一些输出]

[英]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.

相关问题 打印时奇怪的Python输出 - Weird Python output when printing 当我在 python 中打印输出时,它还包括用户输入 - when i am printing output in python it also includes user input 在 python 上运行一些 os-module 代码时,我不断收到 unicode 错误消息(打开 mp3) - I keep getting a unicode error message when running some os-module code on python(opening an mp3) 当我使用 python 中的 def 函数从 Excel 工作表中提取数据时,我得到单引号和双引号 ("",'',[]) 的输出 - When i extract data from excel sheet using def function in python, i am getting output in single and double quotes ("",'',[]) 在python中使用Spritesheet时,我不断收到错误消息 - I keep getting an error when using a spritesheet in python 在 python 中打开文件时,我不断收到“标识符中的无效字符” - I keep getting 'invalid character in identifier' when opening a file in python 在 python 中 ping 我的服务器时,我不断收到误报 - I keep getting false negatives when pinging my server in python Python:从模块导入时生成不同的随机选择(不同的 python 文件) - 保持相同的 output - Python: generate a different random choice when importing from module (different python file) - Keep getting same output 使用Python运行CMD命令,打印输出并将输出作为变量 - Running a CMD command with Python, printing the output AND getting the output as variable 我尝试在 python 中使用 tkinter 进行测验,但出于某种原因,我不断收到错误消息 - I tried making a quiz using tkinter in python and for some reason, i keep getting an error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM