简体   繁体   English

如何从python中的特定列读取Excel数据

[英]How to read data from excel from a particular column in python

I have an excel sheet and I am reading the excel sheet using pandas in python. 我有一个Excel工作表,并且正在使用python中的Pandas阅读Excel工作表。

Now I want to read the excel file based on a column, if the column has some value then do not read that row, if the column is empty than read that and store the values in a list. 现在,我想基于列读取excel文件,如果该列具有某个值,则不读取该行,如果该列为空,则读取该行并将其存储在列表中。

Here is a screenshot 这是截图

Excel Example Excel示例

Now in the above image when the uniqueidentifier is yes then it should not read that value, but if it is empty then it should start reading from that value. 现在在上图中,当uniqueidentifier为yes时,它不应读取该值,但是如果为空,则应从该值开始读取。

How to do that using python and how to get index so that after I have performed some function that I am again able to write to that blank unique identifier column saying that row has been read 如何使用python做到这一点以及如何获取索引,以便在执行某些功能之后,我能够再次写入该空白唯一标识符列,表示已读取该行

This is possible for csv files. 对于csv文件,这是可能的。 There you could do 在那里你可以做

iter_csv = pandas.read_csv('file.csv', iterator=True, chunksize=100000)
df = pd.concat([chunk[chunk['UniqueIdentifier'] == 'True'] for chunk in iter_csv])

But pd.read_excel does not offer to return an iterator object, maybe some other excel-readers can. 但是pd.read_excel不提供返回迭代器对象的功能,也许其他一些excel-reader可以提供。 But I don't no which ones. 但是我也不是哪一个。 Nevertheless you could export your excel file as csv and use the solution for csv files. 不过,您可以将excel文件导出为csv,然后将解决方案用于csv文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM