feat: refactor GUI to multi-page Streamlit app with 9 tool pages
Convert single-page deduplicator into a multi-page suite. Home page shows tool card grid. Deduplicator extracted to its own page (fully working). 8 stub pages added for Text Cleaner, Format Standardizer, Missing Values, Column Mapper, Outlier Detector, Multi-File Merger, Validator & Reporter, and Pipeline Runner — each with functional file upload and coming-soon UI. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
86
src/gui/pages/7_Multi_File_Merger.py
Normal file
86
src/gui/pages/7_Multi_File_Merger.py
Normal file
@@ -0,0 +1,86 @@
|
||||
"""DataTools Multi-File Merger — 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))
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Header
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
st.title("📎 Multi-File Merger")
|
||||
st.caption("Combine multiple CSV and Excel files into one dataset.")
|
||||
|
||||
st.info("This tool is under development.")
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# What this tool will do
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
st.markdown("""
|
||||
**Features:**
|
||||
- Upload multiple CSV/Excel files at once
|
||||
- Automatic schema alignment (matching columns by name)
|
||||
- Append mode: stack files vertically (union)
|
||||
- Join mode: merge files on shared key columns
|
||||
- Handle mismatched columns (fill missing with nulls or drop)
|
||||
- Source file tracking column
|
||||
""")
|
||||
|
||||
st.divider()
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Multi-file upload (functional)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
uploaded_files = st.file_uploader(
|
||||
"Upload CSV or Excel files",
|
||||
type=["csv", "tsv", "xlsx", "xls"],
|
||||
accept_multiple_files=True,
|
||||
help="Upload multiple files to preview. Processing is not yet available.",
|
||||
key="merger_file_upload",
|
||||
)
|
||||
|
||||
if uploaded_files:
|
||||
import pandas as pd
|
||||
for f in uploaded_files:
|
||||
try:
|
||||
if f.name.endswith((".xlsx", ".xls")):
|
||||
df = pd.read_excel(f)
|
||||
else:
|
||||
df = pd.read_csv(f)
|
||||
st.subheader(f"Preview: {f.name}")
|
||||
st.caption(f"{len(df)} rows, {len(df.columns)} columns — Columns: {', '.join(df.columns[:10])}{'...' if len(df.columns) > 10 else ''}")
|
||||
st.dataframe(df.head(5), use_container_width=True)
|
||||
except Exception as e:
|
||||
st.error(f"Failed to read {f.name}: {e}")
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Placeholder options
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
st.subheader("Merge Strategy")
|
||||
|
||||
st.selectbox("Mode", ["Append (stack vertically)", "Join on key columns", "Schema alignment (smart merge)"], disabled=True)
|
||||
st.selectbox("Mismatched columns", ["Fill with null", "Drop non-shared columns", "Error"], disabled=True)
|
||||
st.checkbox("Add source filename column", value=True, disabled=True)
|
||||
|
||||
st.divider()
|
||||
st.button("Merge Files", type="primary", use_container_width=True, disabled=True)
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Footer
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
st.divider()
|
||||
st.caption(
|
||||
"Runs locally. Your data never leaves this computer. "
|
||||
"| DataTools v3.0"
|
||||
)
|
||||
Reference in New Issue
Block a user