Update app.py
Browse files
app.py
CHANGED
|
@@ -101,6 +101,7 @@ def fetch_database_records(std, ver, cat, table_type):
|
|
| 101 |
matched_config = config_df.iloc[0]
|
| 102 |
|
| 103 |
anchors = [x.strip() for x in matched_config['Anchor_Column'].split(',')]
|
|
|
|
| 104 |
|
| 105 |
query = f"SELECT * FROM [{main_table}]"
|
| 106 |
conditions = []
|
|
@@ -123,14 +124,25 @@ def fetch_database_records(std, ver, cat, table_type):
|
|
| 123 |
|
| 124 |
real_anchors = [c for c in df.columns if any(a.lower() == c.lower() for a in anchors)]
|
| 125 |
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
df[c] = df[c].apply(convert_blob_to_html_img)
|
| 132 |
|
| 133 |
-
return df, real_anchors
|
| 134 |
|
| 135 |
except Exception as e:
|
| 136 |
import traceback
|
|
|
|
| 101 |
matched_config = config_df.iloc[0]
|
| 102 |
|
| 103 |
anchors = [x.strip() for x in matched_config['Anchor_Column'].split(',')]
|
| 104 |
+
displays = [x.strip() for x in matched_config['Display_Columns'].split(',')] if pd.notna(matched_config['Display_Columns']) else anchors
|
| 105 |
|
| 106 |
query = f"SELECT * FROM [{main_table}]"
|
| 107 |
conditions = []
|
|
|
|
| 124 |
|
| 125 |
real_anchors = [c for c in df.columns if any(a.lower() == c.lower() for a in anchors)]
|
| 126 |
|
| 127 |
+
final_cols = []
|
| 128 |
+
for d in displays:
|
| 129 |
+
for c in df.columns:
|
| 130 |
+
if d.lower() == c.lower():
|
| 131 |
+
if c not in final_cols:
|
| 132 |
+
final_cols.append(c)
|
| 133 |
+
break
|
| 134 |
+
|
| 135 |
+
for ra in real_anchors:
|
| 136 |
+
if ra not in final_cols:
|
| 137 |
+
final_cols.append(ra)
|
| 138 |
+
|
| 139 |
+
if not final_cols:
|
| 140 |
+
return df, real_anchors
|
| 141 |
+
|
| 142 |
+
for c in final_cols:
|
| 143 |
df[c] = df[c].apply(convert_blob_to_html_img)
|
| 144 |
|
| 145 |
+
return df[final_cols], real_anchors
|
| 146 |
|
| 147 |
except Exception as e:
|
| 148 |
import traceback
|