想要检查 excel sheet 和 python 中是否存在某些值
Want to check certain values are present in the excel sheet with python
我有一个 excel sheet 我想检查是否有特定值
密码是
import openpyxl
book = openpyxl.load_workbook("C:\Users\abdul_saboor\PycharmProjects\sleneiumpythonsession\venv\LoginData.xlsx")
first_sheet = book.get_sheet_by_name('Sheet1')
particular_cell_value = first_sheet.rows
particular_cell_value1 = first_sheet.columns
for x in particular_cell_value:
for j in particular_cell_value1:
if "adm@yourstore.com" in particular_cell_value1:
print("Test case passed")
else:
print("Failed")
但是输出每次都显示失败?我想检查 adm@yourstore.com 是否存在或 not.Can 有人帮忙吗?
使用pandas
:
import pandas as pd
df = pd.read_excel('LoginData.xlsx')
isin = 'adm@yourstore.com' in df['username'].tolist()
print(f"User adm@yourstore.com is in file: {'yes' if isin else 'no'}")
我有一个 excel sheet 我想检查是否有特定值
密码是
import openpyxl
book = openpyxl.load_workbook("C:\Users\abdul_saboor\PycharmProjects\sleneiumpythonsession\venv\LoginData.xlsx")
first_sheet = book.get_sheet_by_name('Sheet1')
particular_cell_value = first_sheet.rows
particular_cell_value1 = first_sheet.columns
for x in particular_cell_value:
for j in particular_cell_value1:
if "adm@yourstore.com" in particular_cell_value1:
print("Test case passed")
else:
print("Failed")
但是输出每次都显示失败?我想检查 adm@yourstore.com 是否存在或 not.Can 有人帮忙吗?
使用pandas
:
import pandas as pd
df = pd.read_excel('LoginData.xlsx')
isin = 'adm@yourstore.com' in df['username'].tolist()
print(f"User adm@yourstore.com is in file: {'yes' if isin else 'no'}")