Update app.py
Browse files
app.py
CHANGED
|
@@ -92,6 +92,7 @@ def update_category_dd(standard, version):
|
|
| 92 |
cols = pd.read_sql(f"PRAGMA table_info([{main_t}])", conn)['name'].tolist()
|
| 93 |
lower = [c.lower() for c in cols]
|
| 94 |
|
|
|
|
| 95 |
if 'chapter' in lower and 'category' in lower:
|
| 96 |
ch = cols[lower.index('chapter')]
|
| 97 |
ca = cols[lower.index('category')]
|
|
@@ -101,18 +102,27 @@ def update_category_dd(standard, version):
|
|
| 101 |
for _, r in df.iterrows():
|
| 102 |
choices.append(f"{str(r[ch]).strip()}.{str(r[ca]).strip()}")
|
| 103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
for t in tables:
|
| 105 |
if t == main_t:
|
| 106 |
continue
|
| 107 |
|
| 108 |
-
|
| 109 |
-
prefix_pattern = f"^{standard}[_\\s-]*{version}[_\\s-]*"
|
| 110 |
-
short_name = re.sub(prefix_pattern, "", t, flags=re.IGNORECASE)
|
| 111 |
-
|
| 112 |
-
# ๋ง์ฝ ํ
์ด๋ธ ์ด๋ฆ์ ๋จ์ ํน์๋ฌธ์๋ ๊ณต๋ฐฑ์ด ๋ณด๊ธฐ ์ซ๋ค๋ฉด ํ ๋ฒ ๋ ์ ๋ฆฌ
|
| 113 |
-
short_name = short_name.strip()
|
| 114 |
|
| 115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
|
| 117 |
conn.close()
|
| 118 |
|
|
|
|
| 92 |
cols = pd.read_sql(f"PRAGMA table_info([{main_t}])", conn)['name'].tolist()
|
| 93 |
lower = [c.lower() for c in cols]
|
| 94 |
|
| 95 |
+
# 1. ์ฑํฐ/์นดํ
๊ณ ๋ฆฌ ๊ธฐ์ค ๋ก์ง (๊ธฐ์กด ์ ์ง)
|
| 96 |
if 'chapter' in lower and 'category' in lower:
|
| 97 |
ch = cols[lower.index('chapter')]
|
| 98 |
ca = cols[lower.index('category')]
|
|
|
|
| 102 |
for _, r in df.iterrows():
|
| 103 |
choices.append(f"{str(r[ch]).strip()}.{str(r[ca]).strip()}")
|
| 104 |
|
| 105 |
+
# 2. ๐ ํ
์ด๋ธ ์ด๋ฆ ๊น๋ํ๊ฒ ์๋ฅด๊ธฐ (๋์๋ฌธ์ ๋ฌด์ ๋ฐฉ์)
|
| 106 |
+
# ์: "r171_00series_"
|
| 107 |
+
prefix = f"{standard}_{version}_".lower()
|
| 108 |
+
prefix_no_under = f"{standard}_{version}".lower()
|
| 109 |
+
|
| 110 |
for t in tables:
|
| 111 |
if t == main_t:
|
| 112 |
continue
|
| 113 |
|
| 114 |
+
t_lower = t.lower()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
+
# ํ
์ด๋ธ ์ด๋ฆ์ด prefix("r171_00series_")๋ก ์์ํ๋ฉด ๊ทธ ๊ธธ์ด๋งํผ ์๋ถ๋ถ์ ์น๋ ์๋ฆ
|
| 117 |
+
if t_lower.startswith(prefix):
|
| 118 |
+
short_name = t[len(prefix):]
|
| 119 |
+
# ํน์ ์ธ๋๋ฐ(_) ์์ด "r171_00seriesTableA" ์ฒ๋ผ ๋ถ์ด์์ ๊ฒฝ์ฐ ๋๋น
|
| 120 |
+
elif t_lower.startswith(prefix_no_under):
|
| 121 |
+
short_name = t[len(prefix_no_under):]
|
| 122 |
+
else:
|
| 123 |
+
short_name = t
|
| 124 |
+
|
| 125 |
+
choices.append(f"{short_name.strip()}")
|
| 126 |
|
| 127 |
conn.close()
|
| 128 |
|