Name, Age, Address
John, 25, 123 Main St.
Jane, 30, 456 Maple Ave.
Bob, 40, 789 Oak Ln.
可以使用Python的csv模块来读取该文件。示例代码如下:
import csv
with open('file.csv') as csvfile:
reader = csv.DictReader(csvfile)
rows = [row for row in reader]
input_name = input('Please enter your name: ')
input_address = input('Please enter your address: ')
match = False
for row in rows:
if input_name == row['Name'] and input_address == row['Address']:
print('Name:', row['Name'])
print('Age:', row['Age'])
print('Address:', row['Address'])
match = True
if not match:
print('No match found.')
以上代码将比较csv文件中的Name和Address列值是否与用户输入的值匹配。如果找到匹配的值,则将输出该行的其他信息。如果未找到匹配则会输出“No match found.”。
这就是比较csv文件值与输入值的解决方法。
上一篇:比较CSV文件与Neo4j结果
下一篇:比较CSV文件中的两个字段