[英]How to check if a string in a list is present in a particular column in a CSV file using python?
我在這里嘗試了以下target_conditions是要與PLM中的列進行比較的列表
csv file
with open('PLM.csv', 'rt') as f:
reader = csv.reader(f, delimiter=',')
for row in reader:
for str in target_conditions:
str=str.split(',')
if str in row[3]:
print ("is in file") #but i need the patient name to be displayed
我修改了代碼以從PLM.csv文件中的列中找到target_conditions列表的值。
with open('PLM.csv', 'rt') as csvfile:
reader = csv.reader(csvfile, delimiter=',')
for row in reader:
for str in target_conditions:
if str in row:
print(row[row.index(str)])
我希望這能幫到您。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.