<< All versions

Skill v1.0.0

currentAutomated scan100/100
hydr0pon1c/skills-on-the-fly/141-20
──Details
PublishedNovember 18, 2026 at 06:53 AM
Content Hashsha256:83d684795e0d6392...
Git SHAfc2c0936b42a
──Files
Files (1 file, 6.1 KB)
SKILL.md6.1 KBactive
SKILL.md · 75 lines · 6.1 KB

metadata: version: "1.0.0"


SKILL.md

When to use

Use this skill when you need to solve a spreadsheet manipulation problem that requires deleting rows across one or more sheets based on a condition that involves matching column values between sheets (or within the same sheet). Typical triggers in the instruction:

  • Keywords like "delete rows", "macro", "matching rows", "find and delete", "remove rows", "based on value in column X and column Y".
  • Sheet-level manipulation instruction type.
  • answer_position defines a range on each sheet that should contain the final output after deletion.
  • The problem involves cross-referencing two separate sheets by one or more key columns and deleting the corresponding rows from both.

Before acting, gather the following evidence from the task context:

  • Exact sheet names (case-sensitive) and column indices (letters or numbers) to compare.
  • Whether the condition is pairwise (each row from sheet A matches exactly one row in sheet B) or set-based (delete all rows that meet a condition across sheets).
  • Whether any rows are marked with a visual highlight (e.g., yellow fill) – ignore the highlight; implement the logical condition.
  • The answer_position ranges – these indicate the expected final data footprint, not a constraint on which rows to delete.
  • The spreadsheet_path and output_path for loading/saving.

Possible Failure Modes

  • Matching columns by value but not by type: treat numbers and strings as distinct (e.g., 9963547 vs "9963547"). Always convert both sides to the same type (str or numeric) before comparison.
  • Ignoring header rows: accidentally delete the header row because it compares None or a column name. Always skip header rows (row 1) when collecting data.
  • Deleting rows in forward order: modifying row indices while iterating forward causes misalignment. Always collect indices first, then delete in reverse order (highest row number to lowest).
  • Modifying a sheet that is not the target: the instruction clearly names the sheets (e.g., "PL Recon Items" and "Statement Recon Items"). Do not modify any other sheet.
  • Handling missing or empty values: matching None or NaN to a numeric value is a common mistake. Use an explicit check for None or pd.isna() and decide whether empty cells are considered a match (usually not intended).
  • Forgetting to save the workbook after all modifications. Ensure the final code saves to the exact output_path.
  • Assuming sorted data – the matching condition is not about row order; it's a cross-join style match. Use a dictionary or set to efficiently look up values from one sheet while iterating over the other.
  • Over-deleting from the second sheet because the same key from sheet A matches multiple rows in sheet B. Only delete the rows that correspond pairwise (one-to-one) unless the instruction says otherwise.

Possible procedures

  1. Load workbook and sheets

Use openpyxl.load_workbook(path) with data_only=True if needed. Get references to both target sheets by name.

  1. Map values from one sheet
  • For the first sheet (e.g., "PL Recon Items"), iterate data rows (skip header). Build a dictionary mapping a composite key (e.g., (invoice_no, amount)) to the row index (1‑based) of that row.
  • If duplicate keys exist, decide whether to delete only the first match or all. Typically, each matching pair is unique.
  1. Identify rows to delete in the second sheet
  • Iterate rows of the second sheet. For each data row, construct the same composite key using corresponding columns.
  • If the key exists in the map from step 2, record the row index from the map (first sheet) and the current row index (second sheet).
  • Collect both row indices into a set for each sheet.
  1. Delete rows in reverse order
  • For each sheet, sort the collected row indices in descending order.
  • Call ws.delete_rows(row_idx) for each.
  • (If using openpyxl, delete_rows shifts rows below upward.)
  1. Preserve other sheets and data

Do not touch any sheet not mentioned in the instruction. If the problem involves only two sheets, leave other sheets unchanged.

  1. Save the workbook to the specified output_path.

Decision points and recovery checks

  • If a column value is `None` or `NaN`: decide to skip that row (since matching requires a value) or treat as a match only if both sides are also empty (rarely intended).
  • If a key appears multiple times in the first sheet: ensure you match them one-to-one (e.g., remove from the map after first match) unless the instruction says "delete all rows that have a matching counterpart".
  • If the `answer_position` shows only a few rows remain: that is the expected outcome; you do not need to verify the exact row count as long as the matching logic is correct.

Verification Checklist

  • [ ] Only the specified sheets are modified – no other sheets in the workbook are changed.
  • [ ] Header rows are preserved in each modified sheet (row 1 stays).
  • [ ] Rows are deleted in reverse order – verify the final row indices are as expected (e.g., after deletion, there should be no duplicate empty rows in the middle).
  • [ ] Cross-sheet matching is correct – for every deleted row in sheet A, there is a corresponding deleted row in sheet B that satisfies the column condition. (You can print or log the pairs during development to sanity‑check.)
  • [ ] No extra rows are left empty or untended: after deletion, data rows are contiguous below the header (unless a blank separator row is intended by the instruction).
  • [ ] Output file is saved at the exact output_path provided in the task context.
  • [ ] No hard‑coded paths or values from retrieved examples are copied. All sheet names, column indices, and match logic come from the current target task context.
  • [ ] No unrelated state is corrupted – e.g., cell formatting, other sheets, or merge cells (if any) remain intact.
  • [ ] Recovery check: if any comparison involves ambiguous types or empty cells, the code explicitly handles them (e.g., str(value).strip() if value is not None else None).
All versions