Add shared hide_streamlit_chrome() helper that removes header bar, hamburger menu, footer, and deploy button via CSS injection. Called on every page. Add .streamlit/config.toml with minimal toolbar mode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
98 lines
3.2 KiB
Python
98 lines
3.2 KiB
Python
"""DataTools Column Mapper — stub page."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import streamlit as st
|
|
|
|
_project_root = Path(__file__).resolve().parent.parent.parent.parent
|
|
if str(_project_root) not in sys.path:
|
|
sys.path.insert(0, str(_project_root))
|
|
|
|
from src.gui.components import hide_streamlit_chrome
|
|
|
|
hide_streamlit_chrome()
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Header
|
|
# ---------------------------------------------------------------------------
|
|
|
|
st.title("🗂️ Column Mapper")
|
|
st.caption("Rename columns, enforce a target schema, and coerce types.")
|
|
|
|
st.info("This tool is under development.")
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# What this tool will do
|
|
# ---------------------------------------------------------------------------
|
|
|
|
st.markdown("""
|
|
**Features:**
|
|
- Rename columns via interactive mapping table
|
|
- Load a target schema (JSON/CSV) to auto-map columns
|
|
- Fuzzy column name matching for automatic suggestions
|
|
- Type coercion (string → int, string → date, etc.)
|
|
- Drop unmapped columns or keep as-is
|
|
- Reorder columns to match target schema
|
|
""")
|
|
|
|
st.divider()
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# File upload (functional)
|
|
# ---------------------------------------------------------------------------
|
|
|
|
uploaded = st.file_uploader(
|
|
"Upload CSV or Excel file",
|
|
type=["csv", "tsv", "xlsx", "xls"],
|
|
help="Upload a file to preview. Processing is not yet available.",
|
|
key="colmap_file_upload",
|
|
)
|
|
|
|
if uploaded is not None:
|
|
import pandas as pd
|
|
try:
|
|
if uploaded.name.endswith((".xlsx", ".xls")):
|
|
df = pd.read_excel(uploaded)
|
|
else:
|
|
df = pd.read_csv(uploaded)
|
|
st.subheader(f"Preview: {uploaded.name}")
|
|
st.caption(f"{len(df)} rows, {len(df.columns)} columns")
|
|
st.dataframe(df.head(10), use_container_width=True)
|
|
|
|
st.subheader("Column Mapping")
|
|
st.caption("Map source columns to target names. (Interactive mapping coming soon.)")
|
|
mapping_data = pd.DataFrame({
|
|
"Source Column": df.columns.tolist(),
|
|
"Target Column": df.columns.tolist(),
|
|
"Type": ["auto"] * len(df.columns),
|
|
})
|
|
st.dataframe(mapping_data, use_container_width=True, hide_index=True)
|
|
except Exception as e:
|
|
st.error(f"Failed to read file: {e}")
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Placeholder options
|
|
# ---------------------------------------------------------------------------
|
|
|
|
st.subheader("Schema Options")
|
|
|
|
st.file_uploader("Load target schema (JSON)", type=["json"], disabled=True, key="colmap_schema")
|
|
st.checkbox("Drop unmapped columns", value=False, disabled=True)
|
|
st.checkbox("Reorder to match schema", value=True, disabled=True)
|
|
|
|
st.divider()
|
|
st.button("Apply Column Mapping", type="primary", use_container_width=True, disabled=True)
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Footer
|
|
# ---------------------------------------------------------------------------
|
|
|
|
st.divider()
|
|
st.caption(
|
|
"Runs locally. Your data never leaves this computer. "
|
|
"| DataTools v3.0"
|
|
)
|