Sakshi
fixed markdown_table_to_json in utils.py
2856ddc
raw
history blame contribute delete
436 Bytes
def markdown_table_to_json(markdown):
lines = markdown.strip().split("\n")
# Extract headers
headers = [h.strip() for h in lines[0].split("|") if h.strip()]
# Extract rows
rows = []
for line in lines[2:]: # Skip header and separator line
values = [v.strip() for v in line.split("|") if v.strip()]
row_dict = dict(zip(headers, values))
rows.append(row_dict)
return rows