Spaces:
Running
Running
File size: 436 Bytes
2856ddc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
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 |