{"data":{"slug":"github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-reading-multi-sheet-reading-f360ac00565f","title":"Multi-sheet Data Cleaning and Analysis","summary":"Read multi-sheet Excel files, dynamically assess data volume to enable Parquet large file optimization, and perform regex cleaning, classification summary, linear fitting, and generate formatted charts and result files.","url":"https:\/\/skillshunter.net\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-reading-multi-sheet-reading-f360ac00565f","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-reading-multi-sheet-reading-f360ac00565f","markdown_url":"https:\/\/skillshunter.net\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-reading-multi-sheet-reading-f360ac00565f.md","download_url":"https:\/\/skillshunter.net\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-reading-multi-sheet-reading-f360ac00565f\/download","category":{"slug":"data-research","name":"Data & Research"},"editor_note":"The tool requires a Python environment with pandas, openpyxl, and matplotlib installed. Users must replace placeholder column names (e.g., '\u76ee\u6807\u6e05\u6d17\u5217', '\u5206\u7c7b\u5217', '\u6570\u503c\u5217', 'X\u8f74\u5217', 'Y\u8f74\u5217') with actual column names in their dataset.","instructions":"---\nname: multi-sheet-reading-and-analysis\ndescription: \"\u7528\u4e8e\u8bfb\u53d6\u591a\u5de5\u4f5c\u8868Excel\u6587\u4ef6\uff0c\u52a8\u6001\u8bc4\u4f30\u6570\u636e\u91cf\u4ee5\u542f\u7528Parquet\u5927\u6587\u4ef6\u4f18\u5316\uff0c\u5e76\u6267\u884c\u6b63\u5219\u6e05\u6d17\u3001\u5206\u7c7b\u6c47\u603b\u3001\u7ebf\u6027\u62df\u5408\u53ca\u751f\u6210\u5e26\u683c\u5f0f\u7684\u56fe\u8868\u4e0e\u7ed3\u679c\u6587\u4ef6\u3002\"\n---\n\nStep1 \u7edf\u8ba1\u591a\u5de5\u4f5c\u8868\u603b\u884c\u6570\uff0c\u5e76\u6839\u636e\u6570\u636e\u91cf\u7ea7\uff08\u5982\u22651\u4e07\u884c\uff09\u52a8\u6001\u542f\u7528Parquet\u683c\u5f0f\u8f6c\u6362\u4ee5\u4f18\u5316\u5927\u6587\u4ef6\u8bfb\u53d6\u6027\u80fd\u3002\n```python\nimport pandas as pd\nimport os\nfrom openpyxl import load_workbook\n\nfile_path = \"your_excel_file.xlsx\"\nxls = pd.ExcelFile(file_path)\nsheet_names = xls.sheet_names\n\n# \u7edf\u8ba1\u6240\u6709sheet\u7684\u6570\u636e\u884c\u6570\ntotal_rows = 0\nfor sheet in sheet_names:\n    wb = load_workbook(file_path, read_only=True, data_only=True)\n    ws = wb[sheet]\n    max_row = ws.max_row\n    data_rows = max_row - 1 if max_row > 0 else 0\n    total_rows += data_rows\n    wb.close()\n\nprint(f\"\u603b\u6570\u636e\u884c\u6570: {total_rows}\")\n\n# \u5927\u6587\u4ef6\u4f18\u5316\uff1a\u8f6c\u6362\u4e3aParquet\u683c\u5f0f\u8bfb\u53d6\nif total_rows >= 10000:\n    df = pd.read_excel(file_path, sheet_name=sheet_names[0])\n    parquet_path = '\/tmp\/temp_data.parquet'\n    df.to_parquet(parquet_path, engine='pyarrow')\n    df = pd.read_parquet(parquet_path)\nelse:\n    df = pd.read_excel(file_path, sheet_name=sheet_names[0])\n```\n\nStep2 \u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u5bf9\u6307\u5b9a\u6587\u672c\u5217\u8fdb\u884c\u6570\u636e\u6e05\u6d17\uff08\u4f8b\u5982\u4ec5\u4fdd\u7559\u4e2d\u6587\u5b57\u7b26\uff09\u3002\n```python\nimport re\n\ndef clean_chinese_text(text):\n    if pd.isna(text):\n        return text\n    s = str(text)\n    # \u63d0\u53d6\u6240\u6709\u4e2d\u6587\u5b57\u7b26\n    chinese_chars = re.findall(r'[\u4e00-\u9fff]', s)\n    cleaned = ''.join(chinese_chars)\n    return cleaned if cleaned != '' else ''\n\ntarget_col = '\u76ee\u6807\u6e05\u6d17\u5217' # \u66ff\u6362\u4e3a\u5b9e\u9645\u5217\u540d\nif target_col in df.columns:\n    df[target_col] = df[target_col].apply(clean_chinese_text)\n```\n\nStep3 \u63d0\u53d6\u5173\u952e\u6570\u636e\u8fdb\u884c\u591a\u7ef4\u5ea6\u5206\u6790\uff08\u5206\u7c7b\u6c47\u603b\u6c42\u6781\u503c\u6216\u53cc\u53d8\u91cf\u7ebf\u6027\u62df\u5408\uff09\u3002\n```python\nimport numpy as np\n\n# \u6a21\u5f0f1\uff1a\u5206\u7c7b\u6c47\u603b\u4e0e\u6781\u503c\u63d0\u53d6\ngroup_col = '\u5206\u7c7b\u5217'\nvalue_col = '\u6570\u503c\u5217'\n# \u793a\u4f8b\u5360\u4f4d\u6570\u636e\u63d0\u53d6\u903b\u8f91\nsummary = pd.DataFrame({\n    group_col: ['\u7c7b\u522bA', '\u7c7b\u522bB', '\u7c7b\u522bC'],\n    value_col: [100, 500, 200]\n})\nmax_idx = summary[value_col].idxmax()\nmax_type = summary.loc[max_idx, group_col]\n\n# \u6a21\u5f0f2\uff1a\u53cc\u53d8\u91cf\u7ebf\u6027\u5173\u7cfb\u5206\u6790\nx_col = 'X\u8f74\u5217'\ny_col = 'Y\u8f74\u5217'\nif x_col in df.columns and y_col in df.columns:\n    x_data = df[x_col].values\n    y_data = df[y_col].values\n    # \u62df\u5408\u7ebf\u6027\u8d8b\u52bf\u7ebf\n    coefficients = np.polyfit(x_data, y_data, 1)\n    trend_line = np.poly1d(coefficients)(x_data)\n```\n\nStep4 \u751f\u6210\u5e26\u6761\u4ef6\u683c\u5f0f\u7684Excel\u62a5\u544a\uff08\u5982\u9ad8\u4eae\u6700\u5927\u503c\uff09\u53ca\u53ef\u89c6\u5316\u56fe\u8868\uff0c\u5e76\u63d0\u4f9b\u4e0b\u8f7d\u94fe\u63a5\u3002\n```python\nfrom openpyxl import Workbook\nfrom openpyxl.styles import PatternFill, Font, Alignment, Border, Side\nimport matplotlib.pyplot as plt\n\n# 1. \u751f\u6210\u5e26\u6837\u5f0f\u6807\u8bb0\u7684Excel\u6587\u4ef6\nwb = Workbook()\nws = wb.active\nws.title = \"\u5206\u6790\u7ed3\u679c\"\n\n# \u5b9a\u4e49\u6837\u5f0f\nheader_fill = PatternFill(start_color=\"4472C4\", end_color=\"4472C4\", fill_type=\"solid\")\nheader_font = Font(name=\"SimHei\", bold=True, color=\"FFFFFF\", size=12)\nhighlight_fill = PatternFill(start_color=\"00B050\", end_color=\"00B050\", fill_type=\"solid\")\nhighlight_font = Font(name=\"SimHei\", bold=True, color=\"FFFFFF\", size=12)\nnormal_font = Font(name=\"SimHei\", size=11)\ncenter_align = Alignment(horizontal=\"center\", vertical=\"center\")\nthin_border = Border(left=Side(style=\"thin\"), right=Side(style=\"thin\"), top=Side(style=\"thin\"), bottom=Side(style=\"thin\"))\n\n# \u5199\u5165\u8868\u5934\u4e0e\u6570\u636e\nheaders = [group_col, value_col]\nfor col, header in enumerate(headers, 1):\n    cell = ws.cell(row=1, column=col, value=header)\n    cell.fill = header_fill\n    cell.font = header_font\n    cell.alignment = center_align\n    cell.border = thin_border\n\nfor row_idx, row in summary.iterrows():\n    c_type = ws.cell(row=row_idx+2, column=1, value=row[group_col])\n    c_val = ws.cell(row=row_idx+2, column=2, value=row[value_col])\n    for cell in [c_type, c_val]:\n        cell.alignment = center_align\n        cell.border = thin_border\n        cell.font = normal_font\n    # \u9ad8\u4eae\u6700\u5927\u503c\u884c\n    if row[group_col] == max_type:\n        c_type.fill = highlight_fill\n        c_type.font = highlight_font\n        c_val.fill = highlight_fill\n        c_val.font = highlight_font\n\noutput_excel_path = \"\/mnt\/data\/analysis_report.xlsx\"\nwb.save(output_excel_path)\n\n# 2. \u751f\u6210\u6563\u70b9\u56fe\u4e0e\u8d8b\u52bf\u7ebf (\u5982\u679c\u5b58\u5728\u62df\u5408\u6570\u636e)\nif 'x_data' in locals():\n    plt.rcParams['font.sans-serif'] = ['SimHei', 'DejaVu Sans']\n    plt.rcParams['axes.unicode_minus'] = False\n    plt.figure(figsize=(10, 6), dpi=100)\n    plt.scatter(x_data, y_data, color='blue', s=80, label='\u6570\u636e\u70b9')\n    plt.plot(x_data, trend_line, color='red', linewidth=2, label=f'\u8d8b\u52bf\u7ebf: y={coefficients[0]:.2f}x+{coefficients[1]:.2f}')\n    plt.xlabel(x_col)\n    plt.ylabel(y_col)\n    plt.title(f'{x_col} vs {y_col} \u6563\u70b9\u56fe\u4e0e\u8d8b\u52bf\u7ebf')\n    plt.legend()\n    plt.grid(True)\n    output_img_path = '\/mnt\/data\/scatter_plot.png'\n    plt.savefig(output_img_path, bbox_inches='tight')\n    plt.close()\n\nprint(f\"\u6587\u4ef6\u5df2\u751f\u6210\uff0c\u4e0b\u8f7d\u94fe\u63a5:\")\nprint(f\"- \u5206\u6790\u62a5\u544a: {output_excel_path}\")\nif 'x_data' in locals():\n    print(f\"- \u8d8b\u52bf\u56fe\u8868: {output_img_path}\")\n```\n","use_cases":["Process Excel files with multiple sheets for data cleaning and analysis","Optimize large data reading for improved processing efficiency","Generate formatted analysis reports and visualized charts"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/OpenSenseNova\/SenseNova-Skills\/blob\/07e7ff8c4bdfd7b79e7402fe94af59d2a5a9749b\/skills\/sn-da-excel-workflow\/capability\/excel-reading\/multi-sheet-reading\/SKILL.md","source_commit":"07e7ff8c4bdfd7b79e7402fe94af59d2a5a9749b","license":null,"version":null,"listing_approved_at":"2026-11-16","created_at":"2026-11-15T09:21:40.000000Z","updated_at":"2026-11-16T05:16:30.000000Z","seo_title":"Multi-sheet Data Cleaning and Analysis Tool","seo_description":"Efficiently process multi-sheet Excel data, supporting regex cleaning, classification summary, linear fitting, and chart generation.","seo_keywords":["Multi-sheet data cleaning","Excel data analysis","Regex cleaning","Classification summary analysis","Linear fitting charts"]}}