Spaces:
Runtime error
Runtime error
File size: 492 Bytes
5072271 dad10fa cfb1f9f 5072271 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | import csv
import re
def extract_pattern(pattern: str, text: str) -> str | None:
matches = re.findall(pattern, text)
if matches:
extracted = matches[-1]
return extracted
else:
return None
def read_csv_to_dicts(file_path) -> list[dict]:
with open(file_path, mode='r', newline='', encoding='utf-8') as csvfile:
csv_reader = csv.DictReader(csvfile)
rows = []
for row in csv_reader:
rows.append(row)
return rows
|