[英]I want to to be able to print the name of the keys in the dictionary then the description, value and quantity
[英]I want to be able to locate a value in excel from python and print the value in the next column
我試圖讓用戶在python中給我一個值,然后代碼在excel文檔中找到該值並從下一列中打印該值。
我似乎找不到任何代碼,而我正在努力自己編寫它,到目前為止,這是我的代碼:
dotill = input("would you like to enter till mode?")
if dotill == "yes":
barcode = input("please start scanning")
find (bardcode) in:
excel_document = openpyxl.load_workbook('scanza.xlsx',data_only=True)
heet = excel_document['completetransaction']
有人可以幫忙嗎?
您可能想看看pandas包。 它提供了與excel的接口。
然后,可以使用來自excel文件的pandas DataFrame來解決您的問題的一部分,該文件的路徑為PATH / TO / WORKSHEET beeing,搜索值TESTVALUE,該值將在以下示例中替換:
import pandas as pd
df = pd.read_excel(PATH/TO/WORKSHEET)
if TESTVALUE in df.values:
print('Value in sheet!')
else:
print('Value not in sheet!')
pd.read_excel(path)從excel文件生成一個DataFrame。 df.values可為您提供一個值數組。 if語句檢查數組中的值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.