简体   繁体   中英

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.

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.

Here is a screenshot

Excel Example

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.

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

This is possible for csv files. 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. But I don't no which ones. Nevertheless you could export your excel file as csv and use the solution for csv files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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