[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6FJXV9XMMF9879GXHSYTS5E":3,"skill-same:01M6FJXV9XMMF9879GXHSYTS5E":61},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":28,"linkOnly":29,"markdownContent":30,"markdownBody":31,"frontMatter":32,"refName":34,"commitSha":35,"skillDirectory":36,"forksCount":37,"repositoryHtmlUrl":38,"repositoryHomepageUrl":6,"ownerHtmlUrl":39,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":40,"install":41,"resources":54},"01M6FJXV9XMMF9879GXHSYTS5E","historical-data-manager",null,"Extract, clean, and organize legacy construction data from archives. Migrate historical project data, cost records, and schedules into modern formats.","kbarbel640-del\u002Fskills","kbarbel640-del","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F255315490?v=4","01M6CJPPQGCCESXMG3K7BBGQ5J","01M6CJPPX2PB2BCZERFVM2C2B3",1,"MIT","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fdatadrivenconstruction\u002Fhistorical-data-manager\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27],"data","historical data manager","migrate","extract","cost","Legacy","clean","organize","project","records","2026-11-10 10:12:30",false,"---\r\nslug: \"historical-data-manager\"\r\ndisplay_name: \"Historical Data Manager\"\r\ndescription: \"Extract, clean, and organize legacy construction data from archives. Migrate historical project data, cost records, and schedules into modern formats.\"\r\n---\r\n\r\n# Historical Data Manager for Construction\r\n\r\n## Overview\r\n\r\nManage legacy construction data from archives, old systems, and historical records. Extract, clean, normalize, and migrate data into modern formats for analysis and benchmarking.\r\n\r\n## Business Case\r\n\r\nConstruction companies accumulate decades of project data in various formats:\r\n- Paper records scanned to PDF\r\n- Legacy database exports (Access, dBase, FoxPro)\r\n- Old spreadsheet formats (Lotus 1-2-3, early Excel)\r\n- Proprietary software exports\r\n- Project closeout documentation\r\n\r\nThis skill helps extract value from historical data for:\r\n- Cost benchmarking and trending\r\n- Productivity analysis over time\r\n- Risk pattern identification\r\n- Estimating improvement\r\n\r\n## Technical Implementation\r\n\r\n### Historical Data Extractor\r\n\r\n```python\r\nfrom dataclasses import dataclass, field\r\nfrom typing import List, Dict, Any, Optional\r\nfrom datetime import datetime\r\nfrom pathlib import Path\r\nimport pandas as pd\r\nimport re\r\nimport json\r\n\r\n@dataclass\r\nclass HistoricalRecord:\r\n    project_id: str\r\n    project_name: str\r\n    year: int\r\n    data_type: str  # cost, schedule, labor, material\r\n    original_format: str\r\n    extracted_data: Dict[str, Any]\r\n    quality_score: float\r\n    notes: List[str] = field(default_factory=list)\r\n\r\nclass HistoricalDataManager:\r\n    \"\"\"Manage extraction and normalization of historical construction data.\"\"\"\r\n\r\n    def __init__(self, archive_path: str):\r\n        self.archive_path = Path(archive_path)\r\n        self.records: List[HistoricalRecord] = []\r\n        self.normalization_rules = self._load_normalization_rules()\r\n\r\n    def scan_archive(self) -> Dict[str, int]:\r\n        \"\"\"Scan archive and categorize files by type.\"\"\"\r\n        file_types = {}\r\n\r\n        for file_path in self.archive_path.rglob('*'):\r\n            if file_path.is_file():\r\n                ext = file_path.suffix.lower()\r\n                file_types[ext] = file_types.get(ext, 0) + 1\r\n\r\n        return file_types\r\n\r\n    def extract_from_legacy_excel(self, file_path: str, year: int) -> List[HistoricalRecord]:\r\n        \"\"\"Extract data from legacy Excel files.\"\"\"\r\n        records = []\r\n\r\n        try:\r\n            # Try different engines for old formats\r\n            try:\r\n                df = pd.read_excel(file_path, engine='openpyxl')\r\n            except:\r\n                df = pd.read_excel(file_path, engine='xlrd')\r\n\r\n            # Detect data type from content\r\n            data_type = self._detect_data_type(df)\r\n\r\n            # Normalize column names\r\n            df = self._normalize_columns(df)\r\n\r\n            # Extract project info\r\n            project_info = self._extract_project_info(df, file_path)\r\n\r\n            record = HistoricalRecord(\r\n                project_id=project_info.get('id', f'LEGACY-{year}-{hash(file_path) % 10000}'),\r\n                project_name=project_info.get('name', Path(file_path).stem),\r\n                year=year,\r\n                data_type=data_type,\r\n                original_format='excel',\r\n                extracted_data=df.to_dict('records'),\r\n                quality_score=self._assess_quality(df)\r\n            )\r\n            records.append(record)\r\n\r\n        except Exception as e:\r\n            print(f\"Error extracting {file_path}: {e}\")\r\n\r\n        return records\r\n\r\n    def extract_from_csv(self, file_path: str, year: int) -> HistoricalRecord:\r\n        \"\"\"Extract data from CSV files with encoding detection.\"\"\"\r\n        # Try different encodings\r\n        encodings = ['utf-8', 'latin-1', 'cp1252', 'iso-8859-1']\r\n\r\n        for encoding in encodings:\r\n            try:\r\n                df = pd.read_csv(file_path, encoding=encoding)\r\n                break\r\n            except:\r\n                continue\r\n\r\n        df = self._normalize_columns(df)\r\n        data_type = self._detect_data_type(df)\r\n\r\n        return HistoricalRecord(\r\n            project_id=f'CSV-{year}-{hash(file_path) % 10000}',\r\n            project_name=Path(file_path).stem,\r\n            year=year,\r\n            data_type=data_type,\r\n            original_format='csv',\r\n            extracted_data=df.to_dict('records'),\r\n            quality_score=self._assess_quality(df)\r\n        )\r\n\r\n    def extract_from_database_export(self, file_path: str, db_type: str) -> List[HistoricalRecord]:\r\n        \"\"\"Extract data from legacy database exports.\"\"\"\r\n        records = []\r\n\r\n        if db_type == 'access':\r\n            # Read Access MDB\u002FACCDB files\r\n            import pyodbc\r\n            conn_str = f'DRIVER={{Microsoft Access Driver (*.mdb, *.accdb)}};DBQ={file_path}'\r\n            conn = pyodbc.connect(conn_str)\r\n\r\n            # Get all tables\r\n            cursor = conn.cursor()\r\n            tables = [row.table_name for row in cursor.tables(tableType='TABLE')]\r\n\r\n            for table in tables:\r\n                df = pd.read_sql(f'SELECT * FROM [{table}]', conn)\r\n                # Process each table...\r\n\r\n            conn.close()\r\n\r\n        return records\r\n\r\n    def normalize_cost_data(self, records: List[HistoricalRecord], base_year: int = 2026) -> pd.DataFrame:\r\n        \"\"\"Normalize historical cost data to current dollars.\"\"\"\r\n        # RSMeans historical cost indices (example values)\r\n        cost_indices = {\r\n            2015: 0.82, 2016: 0.84, 2017: 0.87, 2018: 0.90,\r\n            2019: 0.93, 2020: 0.95, 2021: 0.98, 2022: 1.02,\r\n            2023: 1.06, 2024: 1.10, 2025: 1.14, 2026: 1.18\r\n        }\r\n\r\n        normalized_data = []\r\n\r\n        for record in records:\r\n            if record.data_type == 'cost':\r\n                year_index = cost_indices.get(record.year, 1.0)\r\n                base_index = cost_indices.get(base_year, 1.18)\r\n                escalation_factor = base_index \u002F year_index\r\n\r\n                for item in record.extracted_data:\r\n                    if 'amount' in item or 'cost' in item:\r\n                        original_cost = item.get('amount') or item.get('cost', 0)\r\n                        normalized_item = item.copy()\r\n                        normalized_item['original_cost'] = original_cost\r\n                        normalized_item['normalized_cost'] = original_cost * escalation_factor\r\n                        normalized_item['escalation_factor'] = escalation_factor\r\n                        normalized_item['original_year'] = record.year\r\n                        normalized_item['project_id'] = record.project_id\r\n                        normalized_data.append(normalized_item)\r\n\r\n        return pd.DataFrame(normalized_data)\r\n\r\n    def _detect_data_type(self, df: pd.DataFrame) -> str:\r\n        \"\"\"Detect type of data from column names and content.\"\"\"\r\n        columns_lower = [c.lower() for c in df.columns]\r\n\r\n        if any(c in columns_lower for c in ['cost', 'amount', 'price', 'total', 'budget']):\r\n            return 'cost'\r\n        elif any(c in columns_lower for c in ['start', 'finish', 'duration', 'task', 'activity']):\r\n            return 'schedule'\r\n        elif any(c in columns_lower for c in ['hours', 'labor', 'worker', 'crew']):\r\n            return 'labor'\r\n        elif any(c in columns_lower for c in ['material', 'quantity', 'unit', 'supplier']):\r\n            return 'material'\r\n        else:\r\n            return 'unknown'\r\n\r\n    def _normalize_columns(self, df: pd.DataFrame) -> pd.DataFrame:\r\n        \"\"\"Normalize column names to standard format.\"\"\"\r\n        column_mapping = {\r\n            r'proj.*id': 'project_id',\r\n            r'proj.*name': 'project_name',\r\n            r'desc.*': 'description',\r\n            r'qty|quantity': 'quantity',\r\n            r'unit.*cost|unit.*price': 'unit_cost',\r\n            r'total|amount': 'amount',\r\n            r'start.*date': 'start_date',\r\n            r'end.*date|finish.*date': 'end_date',\r\n            r'dur.*': 'duration',\r\n        }\r\n\r\n        new_columns = {}\r\n        for col in df.columns:\r\n            col_lower = col.lower().strip()\r\n            for pattern, new_name in column_mapping.items():\r\n                if re.match(pattern, col_lower):\r\n                    new_columns[col] = new_name\r\n                    break\r\n\r\n        return df.rename(columns=new_columns)\r\n\r\n    def _assess_quality(self, df: pd.DataFrame) -> float:\r\n        \"\"\"Assess data quality score (0-1).\"\"\"\r\n        if df.empty:\r\n            return 0.0\r\n\r\n        scores = []\r\n\r\n        # Completeness: % of non-null values\r\n        completeness = 1 - (df.isnull().sum().sum() \u002F df.size)\r\n        scores.append(completeness)\r\n\r\n        # Column quality: has meaningful column names\r\n        meaningful_cols = sum(1 for c in df.columns if len(c) > 2 and not c.startswith('Unnamed'))\r\n        col_quality = meaningful_cols \u002F len(df.columns)\r\n        scores.append(col_quality)\r\n\r\n        # Row count: more data is better (capped at 1.0)\r\n        row_score = min(len(df) \u002F 100, 1.0)\r\n        scores.append(row_score)\r\n\r\n        return sum(scores) \u002F len(scores)\r\n\r\n    def _extract_project_info(self, df: pd.DataFrame, file_path: str) -> Dict[str, str]:\r\n        \"\"\"Extract project info from data or filename.\"\"\"\r\n        info = {}\r\n\r\n        # Try to find project info in data\r\n        for col in df.columns:\r\n            if 'project' in col.lower() and 'id' in col.lower():\r\n                info['id'] = str(df[col].iloc[0]) if not df[col].empty else None\r\n            if 'project' in col.lower() and 'name' in col.lower():\r\n                info['name'] = str(df[col].iloc[0]) if not df[col].empty else None\r\n\r\n        # Fallback to filename\r\n        if 'name' not in info:\r\n            info['name'] = Path(file_path).stem\r\n\r\n        return info\r\n\r\n    def _load_normalization_rules(self) -> Dict:\r\n        \"\"\"Load rules for normalizing legacy data.\"\"\"\r\n        return {\r\n            'unit_conversions': {\r\n                'M': 1000,  # Thousand\r\n                'C': 100,   # Hundred\r\n                'LF': 1,    # Linear Foot\r\n                'SF': 1,    # Square Foot\r\n                'CY': 1,    # Cubic Yard\r\n            },\r\n            'date_formats': [\r\n                '%m\u002F%d\u002F%Y', '%m\u002F%d\u002F%y', '%Y-%m-%d',\r\n                '%d-%b-%Y', '%B %d, %Y'\r\n            ]\r\n        }\r\n\r\n    def generate_migration_report(self) -> str:\r\n        \"\"\"Generate report on migrated data.\"\"\"\r\n        report = [\"# Historical Data Migration Report\", \"\"]\r\n\r\n        # Summary\r\n        report.append(\"## Summary\")\r\n        report.append(f\"- Total Records: {len(self.records)}\")\r\n\r\n        by_type = {}\r\n        by_year = {}\r\n        for r in self.records:\r\n            by_type[r.data_type] = by_type.get(r.data_type, 0) + 1\r\n            by_year[r.year] = by_year.get(r.year, 0) + 1\r\n\r\n        report.append(\"\\n### By Data Type\")\r\n        for dt, count in sorted(by_type.items()):\r\n            report.append(f\"- {dt}: {count}\")\r\n\r\n        report.append(\"\\n### By Year\")\r\n        for year, count in sorted(by_year.items()):\r\n            report.append(f\"- {year}: {count}\")\r\n\r\n        # Quality Assessment\r\n        report.append(\"\\n## Data Quality\")\r\n        avg_quality = sum(r.quality_score for r in self.records) \u002F len(self.records) if self.records else 0\r\n        report.append(f\"- Average Quality Score: {avg_quality:.2%}\")\r\n\r\n        low_quality = [r for r in self.records if r.quality_score \u003C 0.5]\r\n        if low_quality:\r\n            report.append(f\"\\n### Low Quality Records ({len(low_quality)})\")\r\n            for r in low_quality[:10]:\r\n                report.append(f\"- {r.project_name} ({r.year}): {r.quality_score:.2%}\")\r\n\r\n        return \"\\n\".join(report)\r\n```\r\n\r\n### Legacy System Connectors\r\n\r\n```python\r\nclass LegacySystemConnector:\r\n    \"\"\"Connect to various legacy construction systems.\"\"\"\r\n\r\n    @staticmethod\r\n    def read_timberline_export(file_path: str) -> pd.DataFrame:\r\n        \"\"\"Read Sage Timberline (now Sage 300) export files.\"\"\"\r\n        # Timberline exports typically have specific format\r\n        df = pd.read_csv(file_path, encoding='cp1252')\r\n\r\n        # Map Timberline columns to standard\r\n        column_map = {\r\n            'JOB': 'project_id',\r\n            'PHASE': 'phase_code',\r\n            'CATEGORY': 'cost_code',\r\n            'DESCRIPTION': 'description',\r\n            'ESTIMATE': 'estimated_cost',\r\n            'ACTUAL': 'actual_cost',\r\n            'COMMITTED': 'committed_cost'\r\n        }\r\n\r\n        return df.rename(columns=column_map)\r\n\r\n    @staticmethod\r\n    def read_primavera_xer(file_path: str) -> Dict[str, pd.DataFrame]:\r\n        \"\"\"Read Primavera P6 XER export files.\"\"\"\r\n        tables = {}\r\n        current_table = None\r\n        current_data = []\r\n        columns = []\r\n\r\n        with open(file_path, 'r', encoding='utf-8') as f:\r\n            for line in f:\r\n                line = line.strip()\r\n                if line.startswith('%T'):\r\n                    # Save previous table\r\n                    if current_table and current_data:\r\n                        tables[current_table] = pd.DataFrame(current_data, columns=columns)\r\n                    # Start new table\r\n                    current_table = line.split('\\t')[1] if '\\t' in line else None\r\n                    current_data = []\r\n                    columns = []\r\n                elif line.startswith('%F'):\r\n                    # Field definitions\r\n                    columns = line.split('\\t')[1:]\r\n                elif line.startswith('%R'):\r\n                    # Data row\r\n                    current_data.append(line.split('\\t')[1:])\r\n\r\n        # Save last table\r\n        if current_table and current_data:\r\n            tables[current_table] = pd.DataFrame(current_data, columns=columns)\r\n\r\n        return tables\r\n\r\n    @staticmethod\r\n    def read_mc2_ice(file_path: str) -> pd.DataFrame:\r\n        \"\"\"Read MC2 ICE estimating export.\"\"\"\r\n        # MC2 ICE format handling\r\n        pass\r\n```\r\n\r\n## Quick Start\r\n\r\n```python\r\n# Initialize manager\r\nmanager = HistoricalDataManager('\u002Farchive\u002Fprojects')\r\n\r\n# Scan archive\r\nfile_types = manager.scan_archive()\r\nprint(f\"Found: {file_types}\")\r\n\r\n# Extract from legacy Excel files\r\nfor year in range(2015, 2024):\r\n    year_path = f'\u002Farchive\u002Fprojects\u002F{year}'\r\n    for file in Path(year_path).glob('*.xls*'):\r\n        records = manager.extract_from_legacy_excel(str(file), year)\r\n        manager.records.extend(records)\r\n\r\n# Normalize cost data to 2026 dollars\r\ncost_records = [r for r in manager.records if r.data_type == 'cost']\r\nnormalized_costs = manager.normalize_cost_data(cost_records, base_year=2026)\r\n\r\n# Generate migration report\r\nreport = manager.generate_migration_report()\r\nprint(report)\r\n\r\n# Export for analysis\r\nnormalized_costs.to_excel('historical_costs_normalized.xlsx', index=False)\r\n```\r\n\r\n## Common Use Cases\r\n\r\n1. **Cost Benchmarking**: Normalize historical costs for comparison\r\n2. **Productivity Analysis**: Track labor productivity over time\r\n3. **Risk Identification**: Find patterns in historical project issues\r\n4. **Estimating Calibration**: Improve estimates with historical data\r\n\r\n## Dependencies\r\n\r\n```bash\r\npip install pandas openpyxl xlrd pyodbc\r\n```\r\n\r\n## Resources\r\n\r\n- **RSMeans Historical Cost Index**: For cost escalation\r\n- **ENR Construction Cost Index**: Alternative escalation source\r\n- **Legacy Format Documentation**: Vendor-specific export formats\r\n","# Historical Data Manager for Construction\r\n\r\n## Overview\r\n\r\nManage legacy construction data from archives, old systems, and historical records. Extract, clean, normalize, and migrate data into modern formats for analysis and benchmarking.\r\n\r\n## Business Case\r\n\r\nConstruction companies accumulate decades of project data in various formats:\r\n- Paper records scanned to PDF\r\n- Legacy database exports (Access, dBase, FoxPro)\r\n- Old spreadsheet formats (Lotus 1-2-3, early Excel)\r\n- Proprietary software exports\r\n- Project closeout documentation\r\n\r\nThis skill helps extract value from historical data for:\r\n- Cost benchmarking and trending\r\n- Productivity analysis over time\r\n- Risk pattern identification\r\n- Estimating improvement\r\n\r\n## Technical Implementation\r\n\r\n### Historical Data Extractor\r\n\r\n```python\r\nfrom dataclasses import dataclass, field\r\nfrom typing import List, Dict, Any, Optional\r\nfrom datetime import datetime\r\nfrom pathlib import Path\r\nimport pandas as pd\r\nimport re\r\nimport json\r\n\r\n@dataclass\r\nclass HistoricalRecord:\r\n    project_id: str\r\n    project_name: str\r\n    year: int\r\n    data_type: str  # cost, schedule, labor, material\r\n    original_format: str\r\n    extracted_data: Dict[str, Any]\r\n    quality_score: float\r\n    notes: List[str] = field(default_factory=list)\r\n\r\nclass HistoricalDataManager:\r\n    \"\"\"Manage extraction and normalization of historical construction data.\"\"\"\r\n\r\n    def __init__(self, archive_path: str):\r\n        self.archive_path = Path(archive_path)\r\n        self.records: List[HistoricalRecord] = []\r\n        self.normalization_rules = self._load_normalization_rules()\r\n\r\n    def scan_archive(self) -> Dict[str, int]:\r\n        \"\"\"Scan archive and categorize files by type.\"\"\"\r\n        file_types = {}\r\n\r\n        for file_path in self.archive_path.rglob('*'):\r\n            if file_path.is_file():\r\n                ext = file_path.suffix.lower()\r\n                file_types[ext] = file_types.get(ext, 0) + 1\r\n\r\n        return file_types\r\n\r\n    def extract_from_legacy_excel(self, file_path: str, year: int) -> List[HistoricalRecord]:\r\n        \"\"\"Extract data from legacy Excel files.\"\"\"\r\n        records = []\r\n\r\n        try:\r\n            # Try different engines for old formats\r\n            try:\r\n                df = pd.read_excel(file_path, engine='openpyxl')\r\n            except:\r\n                df = pd.read_excel(file_path, engine='xlrd')\r\n\r\n            # Detect data type from content\r\n            data_type = self._detect_data_type(df)\r\n\r\n            # Normalize column names\r\n            df = self._normalize_columns(df)\r\n\r\n            # Extract project info\r\n            project_info = self._extract_project_info(df, file_path)\r\n\r\n            record = HistoricalRecord(\r\n                project_id=project_info.get('id', f'LEGACY-{year}-{hash(file_path) % 10000}'),\r\n                project_name=project_info.get('name', Path(file_path).stem),\r\n                year=year,\r\n                data_type=data_type,\r\n                original_format='excel',\r\n                extracted_data=df.to_dict('records'),\r\n                quality_score=self._assess_quality(df)\r\n            )\r\n            records.append(record)\r\n\r\n        except Exception as e:\r\n            print(f\"Error extracting {file_path}: {e}\")\r\n\r\n        return records\r\n\r\n    def extract_from_csv(self, file_path: str, year: int) -> HistoricalRecord:\r\n        \"\"\"Extract data from CSV files with encoding detection.\"\"\"\r\n        # Try different encodings\r\n        encodings = ['utf-8', 'latin-1', 'cp1252', 'iso-8859-1']\r\n\r\n        for encoding in encodings:\r\n            try:\r\n                df = pd.read_csv(file_path, encoding=encoding)\r\n                break\r\n            except:\r\n                continue\r\n\r\n        df = self._normalize_columns(df)\r\n        data_type = self._detect_data_type(df)\r\n\r\n        return HistoricalRecord(\r\n            project_id=f'CSV-{year}-{hash(file_path) % 10000}',\r\n            project_name=Path(file_path).stem,\r\n            year=year,\r\n            data_type=data_type,\r\n            original_format='csv',\r\n            extracted_data=df.to_dict('records'),\r\n            quality_score=self._assess_quality(df)\r\n        )\r\n\r\n    def extract_from_database_export(self, file_path: str, db_type: str) -> List[HistoricalRecord]:\r\n        \"\"\"Extract data from legacy database exports.\"\"\"\r\n        records = []\r\n\r\n        if db_type == 'access':\r\n            # Read Access MDB\u002FACCDB files\r\n            import pyodbc\r\n            conn_str = f'DRIVER={{Microsoft Access Driver (*.mdb, *.accdb)}};DBQ={file_path}'\r\n            conn = pyodbc.connect(conn_str)\r\n\r\n            # Get all tables\r\n            cursor = conn.cursor()\r\n            tables = [row.table_name for row in cursor.tables(tableType='TABLE')]\r\n\r\n            for table in tables:\r\n                df = pd.read_sql(f'SELECT * FROM [{table}]', conn)\r\n                # Process each table...\r\n\r\n            conn.close()\r\n\r\n        return records\r\n\r\n    def normalize_cost_data(self, records: List[HistoricalRecord], base_year: int = 2026) -> pd.DataFrame:\r\n        \"\"\"Normalize historical cost data to current dollars.\"\"\"\r\n        # RSMeans historical cost indices (example values)\r\n        cost_indices = {\r\n            2015: 0.82, 2016: 0.84, 2017: 0.87, 2018: 0.90,\r\n            2019: 0.93, 2020: 0.95, 2021: 0.98, 2022: 1.02,\r\n            2023: 1.06, 2024: 1.10, 2025: 1.14, 2026: 1.18\r\n        }\r\n\r\n        normalized_data = []\r\n\r\n        for record in records:\r\n            if record.data_type == 'cost':\r\n                year_index = cost_indices.get(record.year, 1.0)\r\n                base_index = cost_indices.get(base_year, 1.18)\r\n                escalation_factor = base_index \u002F year_index\r\n\r\n                for item in record.extracted_data:\r\n                    if 'amount' in item or 'cost' in item:\r\n                        original_cost = item.get('amount') or item.get('cost', 0)\r\n                        normalized_item = item.copy()\r\n                        normalized_item['original_cost'] = original_cost\r\n                        normalized_item['normalized_cost'] = original_cost * escalation_factor\r\n                        normalized_item['escalation_factor'] = escalation_factor\r\n                        normalized_item['original_year'] = record.year\r\n                        normalized_item['project_id'] = record.project_id\r\n                        normalized_data.append(normalized_item)\r\n\r\n        return pd.DataFrame(normalized_data)\r\n\r\n    def _detect_data_type(self, df: pd.DataFrame) -> str:\r\n        \"\"\"Detect type of data from column names and content.\"\"\"\r\n        columns_lower = [c.lower() for c in df.columns]\r\n\r\n        if any(c in columns_lower for c in ['cost', 'amount', 'price', 'total', 'budget']):\r\n            return 'cost'\r\n        elif any(c in columns_lower for c in ['start', 'finish', 'duration', 'task', 'activity']):\r\n            return 'schedule'\r\n        elif any(c in columns_lower for c in ['hours', 'labor', 'worker', 'crew']):\r\n            return 'labor'\r\n        elif any(c in columns_lower for c in ['material', 'quantity', 'unit', 'supplier']):\r\n            return 'material'\r\n        else:\r\n            return 'unknown'\r\n\r\n    def _normalize_columns(self, df: pd.DataFrame) -> pd.DataFrame:\r\n        \"\"\"Normalize column names to standard format.\"\"\"\r\n        column_mapping = {\r\n            r'proj.*id': 'project_id',\r\n            r'proj.*name': 'project_name',\r\n            r'desc.*': 'description',\r\n            r'qty|quantity': 'quantity',\r\n            r'unit.*cost|unit.*price': 'unit_cost',\r\n            r'total|amount': 'amount',\r\n            r'start.*date': 'start_date',\r\n            r'end.*date|finish.*date': 'end_date',\r\n            r'dur.*': 'duration',\r\n        }\r\n\r\n        new_columns = {}\r\n        for col in df.columns:\r\n            col_lower = col.lower().strip()\r\n            for pattern, new_name in column_mapping.items():\r\n                if re.match(pattern, col_lower):\r\n                    new_columns[col] = new_name\r\n                    break\r\n\r\n        return df.rename(columns=new_columns)\r\n\r\n    def _assess_quality(self, df: pd.DataFrame) -> float:\r\n        \"\"\"Assess data quality score (0-1).\"\"\"\r\n        if df.empty:\r\n            return 0.0\r\n\r\n        scores = []\r\n\r\n        # Completeness: % of non-null values\r\n        completeness = 1 - (df.isnull().sum().sum() \u002F df.size)\r\n        scores.append(completeness)\r\n\r\n        # Column quality: has meaningful column names\r\n        meaningful_cols = sum(1 for c in df.columns if len(c) > 2 and not c.startswith('Unnamed'))\r\n        col_quality = meaningful_cols \u002F len(df.columns)\r\n        scores.append(col_quality)\r\n\r\n        # Row count: more data is better (capped at 1.0)\r\n        row_score = min(len(df) \u002F 100, 1.0)\r\n        scores.append(row_score)\r\n\r\n        return sum(scores) \u002F len(scores)\r\n\r\n    def _extract_project_info(self, df: pd.DataFrame, file_path: str) -> Dict[str, str]:\r\n        \"\"\"Extract project info from data or filename.\"\"\"\r\n        info = {}\r\n\r\n        # Try to find project info in data\r\n        for col in df.columns:\r\n            if 'project' in col.lower() and 'id' in col.lower():\r\n                info['id'] = str(df[col].iloc[0]) if not df[col].empty else None\r\n            if 'project' in col.lower() and 'name' in col.lower():\r\n                info['name'] = str(df[col].iloc[0]) if not df[col].empty else None\r\n\r\n        # Fallback to filename\r\n        if 'name' not in info:\r\n            info['name'] = Path(file_path).stem\r\n\r\n        return info\r\n\r\n    def _load_normalization_rules(self) -> Dict:\r\n        \"\"\"Load rules for normalizing legacy data.\"\"\"\r\n        return {\r\n            'unit_conversions': {\r\n                'M': 1000,  # Thousand\r\n                'C': 100,   # Hundred\r\n                'LF': 1,    # Linear Foot\r\n                'SF': 1,    # Square Foot\r\n                'CY': 1,    # Cubic Yard\r\n            },\r\n            'date_formats': [\r\n                '%m\u002F%d\u002F%Y', '%m\u002F%d\u002F%y', '%Y-%m-%d',\r\n                '%d-%b-%Y', '%B %d, %Y'\r\n            ]\r\n        }\r\n\r\n    def generate_migration_report(self) -> str:\r\n        \"\"\"Generate report on migrated data.\"\"\"\r\n        report = [\"# Historical Data Migration Report\", \"\"]\r\n\r\n        # Summary\r\n        report.append(\"## Summary\")\r\n        report.append(f\"- Total Records: {len(self.records)}\")\r\n\r\n        by_type = {}\r\n        by_year = {}\r\n        for r in self.records:\r\n            by_type[r.data_type] = by_type.get(r.data_type, 0) + 1\r\n            by_year[r.year] = by_year.get(r.year, 0) + 1\r\n\r\n        report.append(\"\\n### By Data Type\")\r\n        for dt, count in sorted(by_type.items()):\r\n            report.append(f\"- {dt}: {count}\")\r\n\r\n        report.append(\"\\n### By Year\")\r\n        for year, count in sorted(by_year.items()):\r\n            report.append(f\"- {year}: {count}\")\r\n\r\n        # Quality Assessment\r\n        report.append(\"\\n## Data Quality\")\r\n        avg_quality = sum(r.quality_score for r in self.records) \u002F len(self.records) if self.records else 0\r\n        report.append(f\"- Average Quality Score: {avg_quality:.2%}\")\r\n\r\n        low_quality = [r for r in self.records if r.quality_score \u003C 0.5]\r\n        if low_quality:\r\n            report.append(f\"\\n### Low Quality Records ({len(low_quality)})\")\r\n            for r in low_quality[:10]:\r\n                report.append(f\"- {r.project_name} ({r.year}): {r.quality_score:.2%}\")\r\n\r\n        return \"\\n\".join(report)\r\n```\r\n\r\n### Legacy System Connectors\r\n\r\n```python\r\nclass LegacySystemConnector:\r\n    \"\"\"Connect to various legacy construction systems.\"\"\"\r\n\r\n    @staticmethod\r\n    def read_timberline_export(file_path: str) -> pd.DataFrame:\r\n        \"\"\"Read Sage Timberline (now Sage 300) export files.\"\"\"\r\n        # Timberline exports typically have specific format\r\n        df = pd.read_csv(file_path, encoding='cp1252')\r\n\r\n        # Map Timberline columns to standard\r\n        column_map = {\r\n            'JOB': 'project_id',\r\n            'PHASE': 'phase_code',\r\n            'CATEGORY': 'cost_code',\r\n            'DESCRIPTION': 'description',\r\n            'ESTIMATE': 'estimated_cost',\r\n            'ACTUAL': 'actual_cost',\r\n            'COMMITTED': 'committed_cost'\r\n        }\r\n\r\n        return df.rename(columns=column_map)\r\n\r\n    @staticmethod\r\n    def read_primavera_xer(file_path: str) -> Dict[str, pd.DataFrame]:\r\n        \"\"\"Read Primavera P6 XER export files.\"\"\"\r\n        tables = {}\r\n        current_table = None\r\n        current_data = []\r\n        columns = []\r\n\r\n        with open(file_path, 'r', encoding='utf-8') as f:\r\n            for line in f:\r\n                line = line.strip()\r\n                if line.startswith('%T'):\r\n                    # Save previous table\r\n                    if current_table and current_data:\r\n                        tables[current_table] = pd.DataFrame(current_data, columns=columns)\r\n                    # Start new table\r\n                    current_table = line.split('\\t')[1] if '\\t' in line else None\r\n                    current_data = []\r\n                    columns = []\r\n                elif line.startswith('%F'):\r\n                    # Field definitions\r\n                    columns = line.split('\\t')[1:]\r\n                elif line.startswith('%R'):\r\n                    # Data row\r\n                    current_data.append(line.split('\\t')[1:])\r\n\r\n        # Save last table\r\n        if current_table and current_data:\r\n            tables[current_table] = pd.DataFrame(current_data, columns=columns)\r\n\r\n        return tables\r\n\r\n    @staticmethod\r\n    def read_mc2_ice(file_path: str) -> pd.DataFrame:\r\n        \"\"\"Read MC2 ICE estimating export.\"\"\"\r\n        # MC2 ICE format handling\r\n        pass\r\n```\r\n\r\n## Quick Start\r\n\r\n```python\r\n# Initialize manager\r\nmanager = HistoricalDataManager('\u002Farchive\u002Fprojects')\r\n\r\n# Scan archive\r\nfile_types = manager.scan_archive()\r\nprint(f\"Found: {file_types}\")\r\n\r\n# Extract from legacy Excel files\r\nfor year in range(2015, 2024):\r\n    year_path = f'\u002Farchive\u002Fprojects\u002F{year}'\r\n    for file in Path(year_path).glob('*.xls*'):\r\n        records = manager.extract_from_legacy_excel(str(file), year)\r\n        manager.records.extend(records)\r\n\r\n# Normalize cost data to 2026 dollars\r\ncost_records = [r for r in manager.records if r.data_type == 'cost']\r\nnormalized_costs = manager.normalize_cost_data(cost_records, base_year=2026)\r\n\r\n# Generate migration report\r\nreport = manager.generate_migration_report()\r\nprint(report)\r\n\r\n# Export for analysis\r\nnormalized_costs.to_excel('historical_costs_normalized.xlsx', index=False)\r\n```\r\n\r\n## Common Use Cases\r\n\r\n1. **Cost Benchmarking**: Normalize historical costs for comparison\r\n2. **Productivity Analysis**: Track labor productivity over time\r\n3. **Risk Identification**: Find patterns in historical project issues\r\n4. **Estimating Calibration**: Improve estimates with historical data\r\n\r\n## Dependencies\r\n\r\n```bash\r\npip install pandas openpyxl xlrd pyodbc\r\n```\r\n\r\n## Resources\r\n\r\n- **RSMeans Historical Cost Index**: For cost escalation\r\n- **ENR Construction Cost Index**: Alternative escalation source\r\n- **Legacy Format Documentation**: Vendor-specific export formats\r\n",{"slug":5,"description":7,"display_name":33},"Historical Data Manager","main","e7e336ac628c3e3bd771aff1aaa469c93778f94a","skills\u002Fdatadrivenconstruction\u002Fhistorical-data-manager",0,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del","2026-08-23 22:39:37",{"source":8,"skillName":5,"commands":42,"prompt":52,"zipAvailable":53},[43,46,49],{"tool":44,"command":45},"npx","npx skills add kbarbel640-del\u002Fskills --skill historical-data-manager",{"tool":47,"command":48},"bunx","bunx skills add kbarbel640-del\u002Fskills --skill historical-data-manager",{"tool":50,"command":51},"pnpm","pnpm dlx skills add kbarbel640-del\u002Fskills --skill historical-data-manager","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fdatadrivenconstruction\u002Fhistorical-data-manager\u002FSKILL.md",true,[55],{"path":56,"resourceType":57,"resourceTypeDesc":58,"sizeBytes":59,"sourceHtmlUrl":60},"_meta.json","REFERENCE","参考文档",314,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fdatadrivenconstruction\u002Fhistorical-data-manager\u002F_meta.json",[62,88,112,130,135,155],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":28},"01M6G8J55967D6281ACMKAKTEQ","crowd-prompting","A marketplace where AI agents improve prompts, system instructions, tool descriptions, and other text-based content with domain expertise from real-world operations — and earn tokens for valuable contributions.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzzadrian\u002Fcrowd-prompting\u002FSKILL.md",[],[69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87],"crowd prompting","prompting","api","with","tokens","domain","world","prompts","operations","instructions","text","tool","system","improve","productivity","marketplace","https","content","ai agents",{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":28},"01M6G8J0PKPAYVET6BWE8W4C26","dilemm-ai","Compete in DilemmAI, the prisoner's dilemma AI arena at dilemm.ai. Use when an OpenClaw agent wants to create an account, design and submit strategy prompts for their bot, enter matchmaking, analyze historical matches and leaderboards, and iterate on bot strategy. Requires headless browser automation (no API available yet).","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzyori\u002Fdilemm-ai\u002FSKILL.md",[],[95,71,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,76,111],"dilemm ai","arena","analyze","browser","openclaw agent","create","automation","browser automation","bot","openclaw","design","strategy","headless","compete","submit","matchmaking","use",{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":28},"01M6G8HWAF3K9SW7NP3Z83CPJ6","arxiv-paper-reviews","Interact with arXiv Crawler API to fetch papers, read reviews, and submit comments. Use when working with arXiv papers, fetching paper lists by date\u002Fcategory\u002Finterest, viewing paper details with comments, or submitting paper reviews via API at http:\u002F\u002F150.158.152.82:8000.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzxrys\u002Fweak-accept\u002FSKILL.md",[],[119,120,121,122,123,124,125,72,126,109,111,127,71,128,129],"arxiv paper reviews","reviews","arxiv","paper","crawler","papers","comments","fetch","read","http","via",{"skillNo":131,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":132,"categories":133,"keywords":134,"publishedAt":28},"01M6G8HQJ7N7WMY6YV7D7SSJ16","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzxrys\u002Farxiv-paper-reviews\u002FSKILL.md",[],[122,121,120,119,129,124,125,72,123,109,111,126,127,71,128],{"skillNo":136,"name":137,"nameZh":6,"description":138,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":139,"categories":140,"keywords":141,"publishedAt":28},"01M6G8HM95Y64JNVFC2HN4E2BG","git-summary","Get a quick summary of the current Git repository including status, recent commits, branches, and contributors.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzweack\u002Fgit-summary\u002FSKILL.md",[],[142,143,144,145,146,147,148,149,150,151,152,153,154],"git","summary","git summary","commits","repository","win32","status","linux","contributors","true","quick","get","branches",{"skillNo":156,"name":157,"nameZh":6,"description":158,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":159,"categories":160,"keywords":161,"publishedAt":28},"01M6G8HGEGF05CNEJCGVYFSC4R","agent-constitution","Interact with AgentConstitution governance contracts on Base Sepolia. Check compliance, read rules, log actions, query governance state.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fztsalexey\u002Fagent-constitution\u002FSKILL.md",[],[162,163,164,165,72,166,167,34,168,127,169,170,171,172,173,85,174,175,176],"agent constitution","constitution","contracts","tree","query","base","log","check","Rules","projects","compliance","actions","state","governance","github"]