{"data":{"slug":"github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-reading-structured-header-reading-a0f7fde2a0af","title":"Excel Text Cleaning and Column Statistics Analysis","summary":"This skill is used to clean Excel text fields and count the number of values in specific columns, suitable for data preprocessing and analysis tasks.","url":"https:\/\/skillshunter.net\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-reading-structured-header-reading-a0f7fde2a0af","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-reading-structured-header-reading-a0f7fde2a0af","markdown_url":"https:\/\/skillshunter.net\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-reading-structured-header-reading-a0f7fde2a0af.md","download_url":"https:\/\/skillshunter.net\/skills\/github-opensensenova-sensenova-skills-skills-sn-da-excel-workflow-capability-excel-reading-structured-header-reading-a0f7fde2a0af\/download","category":{"slug":"data-research","name":"Data & Research"},"editor_note":"The skill requires a pandas DataFrame as input and uses regular expressions to extract pure Chinese characters from text fields. It also dynamically identifies columns containing specific keywords and counts values in those columns.","instructions":"---\nname: excel-large-file-processing-and-cleaning\ndescription: \"\u8bfb\u53d6\u591a sheet Excel \u6587\u4ef6\uff0c\u52a8\u6001\u8bc6\u522b\u76ee\u6807\u5217\u8fdb\u884c\u7edf\u8ba1\uff0c\u5e76\u4f7f\u7528\u6b63\u5219\u6e05\u6d17\u6587\u672c\u5b57\u6bb5\u63d0\u53d6\u4e2d\u6587\u5b57\u7b26\uff0c\u6700\u7ec8\u8f93\u51fa\u6807\u51c6\u5316 Excel \u6587\u4ef6\u3002\"\n---\n\n# Skill Steps\n\n> This sub-skill covers one capability of the Excel workflow. For reading\/counting\/Parquet optimization, see the parent workflow SKILL.md.\n\nStep1 \u6587\u672c\u5b57\u6bb5\u6e05\u6d17\uff0c\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u63d0\u53d6\u7eaf\u4e2d\u6587\u5b57\u7b26\uff08\u8fc7\u6ee4\u6570\u5b57\u3001\u7279\u6b8a\u7b26\u53f7\u7b49\uff09\u3002\n```python\nimport re\n\ndef extract_chinese(text):\n    if pd.isna(text):\n        return text\n    # \u4ec5\u4fdd\u7559 Unicode \u4e2d\u6587\u5b57\u7b26\u8303\u56f4\n    chinese_chars = re.findall(r'[\u4e00-\u9fa5]', str(text))\n    cleaned = ''.join(chinese_chars)\n    return cleaned if cleaned else ''\n\nclean_col = '\u76ee\u6807\u6e05\u6d17\u5217' # \u5360\u4f4d\u793a\u4f8b\uff0c\u5982'\u6536\u8d27\u4eba'\nif clean_col in df.columns:\n    df[clean_col] = df[clean_col].apply(extract_chinese)\n```\n\nStep2 \u52a8\u6001\u6a21\u7cca\u5339\u914d\u5217\u540d\uff0c\u5e76\u7edf\u8ba1\u8be5\u5217\u4e2d\u7279\u5b9a\u503c\u7684\u6570\u91cf\u3002\n```python\n# \u52a8\u6001\u67e5\u627e\u5305\u542b\u7279\u5b9a\u5173\u952e\u5b57\u7684\u5217\nkeyword = 'type'\ntarget_val = 'varchar'\ntarget_col = next((col for col in df.columns if keyword in str(col).lower()), None)\n\ntotal_target_count = 0\ndetails = []\n\nif target_col is not None:\n    # \u5ffd\u7565\u5927\u5c0f\u5199\u548c\u9996\u5c3e\u7a7a\u683c\u8fdb\u884c\u5339\u914d\n    mask = df[target_col].astype(str).str.lower().str.strip() == target_val\n    count = mask.sum()\n    total_target_count += count\n    \n    if count > 0:\n        details.append({\n            'sheet': target_sheet,\n            'target_count': count,\n            'total_rows': len(df)\n        })\n\nprint(f\"{'='*50}\")\nprint(f\"\u5339\u914d\u5217 '{target_col}' \u4e2d\u503c\u4e3a '{target_val}' \u7684\u603b\u6570: {total_target_count}\")\nprint(f\"{'='*50}\")\nfor detail in details:\n    print(f\"  {detail['sheet']}: {detail['target_count']} \u4e2a\u5339\u914d\u9879 (\u5171 {detail['total_rows']} \u884c)\")\n```\n\nStep3 \u5c06\u6e05\u6d17\u548c\u5904\u7406\u540e\u7684\u6570\u636e\u4fdd\u5b58\u4e3a Excel\uff0c\u5e76\u8f93\u51fa\u6587\u4ef6\u5927\u5c0f\u4e0e\u4e0b\u8f7d\u94fe\u63a5\u3002\n```python\noutput_path = \"\/mnt\/data\/cleaned_data_output.xlsx\"\ndf.to_excel(output_path, index=False)\n\nfile_size = os.path.getsize(output_path)\nprint(f\"\u6e05\u6d17\u540e\u7684\u6570\u636e\u5df2\u4fdd\u5b58\u81f3: {output_path}\")\nprint(f\"\u6587\u4ef6\u5927\u5c0f: {file_size} \u5b57\u8282\")\n# \u751f\u6210\u6807\u51c6\u4e0b\u8f7d\u94fe\u63a5\u683c\u5f0f\nprint(f\"\u4e0b\u8f7d\u94fe\u63a5: sandbox:{output_path}\")\n```\n","use_cases":["Clean text fields in Excel and extract pure Chinese characters.","Count the number of specific values in a column that contains specific keywords.","Save the cleaned data as an Excel file and generate a download link."],"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\/structured-header-reading\/SKILL.md","source_commit":"07e7ff8c4bdfd7b79e7402fe94af59d2a5a9749b","license":null,"version":null,"listing_approved_at":"2026-11-16","created_at":"2026-11-15T09:36:35.000000Z","updated_at":"2026-11-16T05:16:30.000000Z","seo_title":"Excel Text Cleaning and Column Statistics Analysis","seo_description":"Clean Excel text fields and count the number of values in specific columns, suitable for data preprocessing and analysis tasks.","seo_keywords":["Excel text cleaning","Excel column statistics","data preprocessing","text field cleaning","Excel data analysis"]}}