Spaces:
No application file
No application file
Update test.py
Browse files
test.py
CHANGED
|
@@ -3,6 +3,26 @@ import re
|
|
| 3 |
|
| 4 |
import pandas as pd
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
# Load your data (replace 'your_file.csv' with the actual file path)
|
| 7 |
merge_data = pd.read_csv('your_file.csv')
|
| 8 |
|
|
|
|
| 3 |
|
| 4 |
import pandas as pd
|
| 5 |
|
| 6 |
+
def extract_table(text):
|
| 7 |
+
# Find the start and end of the table
|
| 8 |
+
start = text.find("| Biomarker Name |")
|
| 9 |
+
end = text.rfind("|", start)
|
| 10 |
+
|
| 11 |
+
# Extract the table portion
|
| 12 |
+
table_text = text[start:end].strip()
|
| 13 |
+
|
| 14 |
+
# Convert the table to a list of rows
|
| 15 |
+
rows = [row.strip().split("|")[1:-1] for row in table_text.split("\n") if "|" in row]
|
| 16 |
+
|
| 17 |
+
# Create a DataFrame from the rows
|
| 18 |
+
df = pd.DataFrame(rows[1:], columns=rows[0])
|
| 19 |
+
return df
|
| 20 |
+
|
| 21 |
+
# Extract the final result table
|
| 22 |
+
df_final_result = extract_table(llm_response)
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
|
| 26 |
# Load your data (replace 'your_file.csv' with the actual file path)
|
| 27 |
merge_data = pd.read_csv('your_file.csv')
|
| 28 |
|