import csv
def get_search_terms():
return input("Вводи данные пёс, и разделить не забудь ';': ").split(';')
def find_matches_in_csv(file_name, search_terms):
found_entries = []
with open(file_name, 'r', encoding='utf-8') as csv_file:
reader = csv.reader(csv_file, delimiter=';')
next(reader)
for row in reader:
if any(term.lower() in entry.lower() for entry in row for term in search_terms):
formatted_row = '; '.join([x for x in row if x])
found_entries.append(formatted_row)
return found_entries
if __name__ == "__main__":
FILE_PATH = 'krasna.csv'
terms_to_search = get_search_terms()
matching_entries = find_matches_in_csv(FILE_PATH, terms_to_search)
if matching_entries:
for entry in matching_entries:
print(entry)
else:
print("Не найдено")
Результат:
978196782; Віталій; Даниленко; Андрійович