{"skills":[{"name":"Clean a spreadsheet without losing information","description":"Apply the column rules a data owner has agreed, preserving uncertainty wherever a cleaner would otherwise silently alter a record.","content":"# Clean a spreadsheet without losing information\n\nApply the column rules a data owner has agreed, preserving uncertainty wherever a cleaner would otherwise silently alter a record.\n\n## When to use this skill\n\n- Someone wants a messy export tidied before analysis, import or sharing.\n- The data has IDs with leading zeros, mixed date formats or placeholders such as NA, N\/A or blanks.\n- Someone wants duplicates removed and it is not clear whether the repeated rows are real records.\n\n## When not to use it\n\n- Rebuilding a file whose rows, quotes or columns broke during import. Use the CSV import rescue skill first.\n- Filling in missing values or correcting suspected errors. The skill marks them for the data owner; imputation is an analysis decision.\n\n## What you need\n\n- Raw table and the column contract for identifiers, dates, amounts and missing values.\n- The intended unit of observation and any authorised duplicate-removal rule.\n\n## Ask before you start\n\nIf any of these are missing or unclear, ask before doing the work.\n\n- What does each row represent, such as one customer, one order or one transaction? That decides whether repeated rows are duplicates.\n- Which columns are identifiers, dates and amounts, and what date order and decimal style does the source use?\n- Which values mean missing, and in which columns, such as blank, NA or N\/A?\n\n## Method\n\n1. Work on a copy that keeps the original row order and row count. Write down each transformation before applying it.\n2. Import every column as text first, with automatic type detection and default missing-value markers switched off, then convert column by column. Excel strips leading zeros, Power Query guesses types from the first 200 rows, and pandas reads NA and N\/A as missing in every column unless told otherwise.\n3. Use the declared date convention. With an unknown convention, convert only dates whose reading is certain, such as ISO dates or a day above 12. Keep an ambiguous value as supplied and record its location.\n4. Convert amounts using the stated locale and distinguish numeric zero from an empty amount. Apply missing markers only to the columns they are declared for. Never reconstruct leading zeros already lost in a numeric export.\n5. Remove a row only under a declared identity rule for the unit of observation. Keep repeated customer IDs when the rows are transactions.\n6. Compare row counts and the count of non-missing values in each converted column before and after. Return the coordinates of every unresolved cell for the data owner.\n\n## Checks before you deliver\n\n- A repeated person can make several purchases. Removing a row requires a record-level identity rule.\n- A syntactically valid date in both day-first and month-first formats offers no evidence about which was intended.\n- Default import settings turn NA, N\/A and blank into missing in every column, so a real code such as the area NA disappears.\n- Numeric import turns 009 and 9 into the same number, merging two different identifiers.\n- Turning a blank amount into zero changes totals and averages.\n\n## How to present the result\n\nLead with what changed and the row counts before and after, which should match unless a declared rule removed rows. Then give the cleaned table, followed by a list of cells left as supplied for the owner to decide, each with its row, column, value and the question to answer. Include the column rules applied so the clean can be repeated.\n\n## Worked example\n\n**Request:** Clean the purchases. Date order is unknown. Empty prices mean missing. Pounds use a decimal point.\n\n**Supplied material:**\n\n```text\ncustomer,date,price\n00123,03\/04\/2026,\n00123,2026-04-05,0\n```\n\n**Answer:** Keep both purchases under the text ID 00123. Leave the first date as 03\/04\/2026 for the owner to resolve and its price as missing. The second row is dated 2026-04-05 and has a genuine price of zero.\n\n## Structured output for tests\n\nFor an ordinary job, answer in the format above and point back to the supplied evidence. Use this structure only for the test cases published with this skill, or when someone asks for structured JSON.\n\nReturn rows in original order, preserving the actual column names and all unmodified fields. Keep identifiers as text, established dates as ISO dates, declared amounts as numbers and agreed missing markers as null. Keep unresolved values as supplied and list their coordinates in review as dataRow.column, starting at data row 1.\n\n## Sources\n\n- [W3C: Metadata vocabulary for tabular data](https:\/\/www.w3.org\/TR\/tabular-metadata\/): The W3C Recommendation lets each column declare its datatype and the strings that count as null, and defines a primary key whose values must be unique for each row. The skill follows the same idea: a per-column contract decides what counts as missing, a date or an identifier.\n- [Microsoft Power Query: data types](https:\/\/learn.microsoft.com\/en-us\/power-query\/data-types): For Excel, CSV and text files Power Query detects column types automatically from the first 200 rows, and it interprets dates and numbers using the locale. Microsoft's example shows UK day\/month dates failing under a US locale until the column is converted with the right locale.\n- [Microsoft Excel: keeping leading zeros and large numbers](https:\/\/support.microsoft.com\/en-us\/office\/keeping-leading-zeros-and-large-numbers-1bf7b935-36e1-4985-842f-5dfa51f85fe7): Microsoft says Excel automatically removes leading zeros, shows large numbers in scientific notation and keeps only 15 digits, and recommends setting such columns to text when importing through From Text\/CSV.\n\nTest cases and an answer checker for this skill: https:\/\/skills.raq.com\/skills\/clean-a-spreadsheet-safely\n","scope":"contextual","trigger_keywords":["Clean a spreadsheet without losing information","clean-a-spreadsheet-safely","clean a spreadsheet safely","Can you tidy this messy export without losing any of the data?","Can you tidy this messy export without losing any of the data","clean this spreadsheet","clean my spreadsheet","clean up this spreadsheet"],"is_private":true,"is_active":true,"scripts":[{"name":"clean-a-spreadsheet-safely-check","description":"Compare a saved JSON answer with a published test. Pass tests\/case-1\/expected.json (or another case) and the path to your answer.","language":"python","filename":"clean-a-spreadsheet-safely-check.py","content":"from pathlib import Path\nimport runpy\n\nrunpy.run_path(str(Path(__file__).parent \/ 'tests' \/ 'check.py'), run_name='__main__')\n","supporting_files":[{"path":"SKILL.md","content":"---\nname: clean-a-spreadsheet-safely\ndescription: \"Clean a spreadsheet or CSV to an agreed column contract without losing information: keep IDs as text, convert only unambiguous dates, honour declared missing values and keep genuine repeat rows. Use when someone asks to clean, tidy or standardise a spreadsheet or export before analysis or import.\"\nlicense: CC-BY-4.0\nmetadata:\n  author: Raq.com\n  version: \"2026-11-22\"\n  homepage: https:\/\/skills.raq.com\/skills\/clean-a-spreadsheet-safely\n---\n\n# Clean a spreadsheet without losing information\n\nApply the column rules a data owner has agreed, preserving uncertainty wherever a cleaner would otherwise silently alter a record.\n\n## When to use this skill\n\n- Someone wants a messy export tidied before analysis, import or sharing.\n- The data has IDs with leading zeros, mixed date formats or placeholders such as NA, N\/A or blanks.\n- Someone wants duplicates removed and it is not clear whether the repeated rows are real records.\n\n## When not to use it\n\n- Rebuilding a file whose rows, quotes or columns broke during import. Use the CSV import rescue skill first.\n- Filling in missing values or correcting suspected errors. The skill marks them for the data owner; imputation is an analysis decision.\n\n## What you need\n\n- Raw table and the column contract for identifiers, dates, amounts and missing values.\n- The intended unit of observation and any authorised duplicate-removal rule.\n\n## Ask before you start\n\nIf any of these are missing or unclear, ask before doing the work.\n\n- What does each row represent, such as one customer, one order or one transaction? That decides whether repeated rows are duplicates.\n- Which columns are identifiers, dates and amounts, and what date order and decimal style does the source use?\n- Which values mean missing, and in which columns, such as blank, NA or N\/A?\n\n## Method\n\n1. Work on a copy that keeps the original row order and row count. Write down each transformation before applying it.\n2. Import every column as text first, with automatic type detection and default missing-value markers switched off, then convert column by column. Excel strips leading zeros, Power Query guesses types from the first 200 rows, and pandas reads NA and N\/A as missing in every column unless told otherwise.\n3. Use the declared date convention. With an unknown convention, convert only dates whose reading is certain, such as ISO dates or a day above 12. Keep an ambiguous value as supplied and record its location.\n4. Convert amounts using the stated locale and distinguish numeric zero from an empty amount. Apply missing markers only to the columns they are declared for. Never reconstruct leading zeros already lost in a numeric export.\n5. Remove a row only under a declared identity rule for the unit of observation. Keep repeated customer IDs when the rows are transactions.\n6. Compare row counts and the count of non-missing values in each converted column before and after. Return the coordinates of every unresolved cell for the data owner.\n\n## Checks before you deliver\n\n- A repeated person can make several purchases. Removing a row requires a record-level identity rule.\n- A syntactically valid date in both day-first and month-first formats offers no evidence about which was intended.\n- Default import settings turn NA, N\/A and blank into missing in every column, so a real code such as the area NA disappears.\n- Numeric import turns 009 and 9 into the same number, merging two different identifiers.\n- Turning a blank amount into zero changes totals and averages.\n\n## How to present the result\n\nLead with what changed and the row counts before and after, which should match unless a declared rule removed rows. Then give the cleaned table, followed by a list of cells left as supplied for the owner to decide, each with its row, column, value and the question to answer. Include the column rules applied so the clean can be repeated.\n\n## Worked example\n\n**Request:** Clean the purchases. Date order is unknown. Empty prices mean missing. Pounds use a decimal point.\n\n**Supplied material:**\n\n```text\ncustomer,date,price\n00123,03\/04\/2026,\n00123,2026-04-05,0\n```\n\n**Answer:** Keep both purchases under the text ID 00123. Leave the first date as 03\/04\/2026 for the owner to resolve and its price as missing. The second row is dated 2026-04-05 and has a genuine price of zero.\n\n## Structured output for tests\n\nFor an ordinary job, answer in the format above and point back to the supplied evidence. Use this structure only for the test cases published with this skill, or when someone asks for structured JSON.\n\nReturn rows in original order, preserving the actual column names and all unmodified fields. Keep identifiers as text, established dates as ISO dates, declared amounts as numbers and agreed missing markers as null. Keep unresolved values as supplied and list their coordinates in review as dataRow.column, starting at data row 1.\n\n## Sources\n\n- [W3C: Metadata vocabulary for tabular data](https:\/\/www.w3.org\/TR\/tabular-metadata\/): The W3C Recommendation lets each column declare its datatype and the strings that count as null, and defines a primary key whose values must be unique for each row. The skill follows the same idea: a per-column contract decides what counts as missing, a date or an identifier.\n- [Microsoft Power Query: data types](https:\/\/learn.microsoft.com\/en-us\/power-query\/data-types): For Excel, CSV and text files Power Query detects column types automatically from the first 200 rows, and it interprets dates and numbers using the locale. Microsoft's example shows UK day\/month dates failing under a US locale until the column is converted with the right locale.\n- [Microsoft Excel: keeping leading zeros and large numbers](https:\/\/support.microsoft.com\/en-us\/office\/keeping-leading-zeros-and-large-numbers-1bf7b935-36e1-4985-842f-5dfa51f85fe7): Microsoft says Excel automatically removes leading zeros, shows large numbers in scientific notation and keeps only 15 digits, and recommends setting such columns to text when importing through From Text\/CSV.\n\nTest cases and an answer checker for this skill: https:\/\/skills.raq.com\/skills\/clean-a-spreadsheet-safely\n"},{"path":"LICENSE.txt","content":"Original Raq.com instructions and synthetic examples: CC BY 4.0.\nhttps:\/\/creativecommons.org\/licenses\/by\/4.0\/\nAttribution: Raq.com, https:\/\/skills.raq.com\/skills\/clean-a-spreadsheet-safely\nReferenced third-party materials retain their own terms.\n"},{"path":"examples\/worked-example.md","content":"# Two purchases, one customer\n\nClean the purchases. Date order is unknown. Empty prices mean missing. Pounds use a decimal point.\n\n## Supplied material\n\ncustomer,date,price\n00123,03\/04\/2026,\n00123,2026-04-05,0\n\n## Worked answer\n\nKeep both purchases under the text ID 00123. Leave the first date as 03\/04\/2026 for the owner to resolve and its price as missing. The second row is dated 2026-04-05 and has a genuine price of zero.\n\n## Reasoning\n\nThe customer occurs twice. Neither the ambiguous date nor the missing price can be inferred from the second purchase.\n"},{"path":"tests\/check.py","content":"\"\"\"Check a saved agent answer locally with Python 3 (standard library only).\"\"\"\nimport json\nimport math\nimport sys\nfrom pathlib import Path\n\n\ndef compare(expected, actual, path=\"$\", accepted=None):\n    if isinstance(expected, bool) or isinstance(actual, bool):\n        if expected is not actual:\n            yield path\n    elif isinstance(expected, (int, float)) and isinstance(actual, (int, float)):\n        if not math.isclose(expected, actual, rel_tol=0, abs_tol=1e-8):\n            yield path\n    elif isinstance(expected, dict) and isinstance(actual, dict):\n        for key in sorted(set(expected) | set(actual)):\n            if key not in expected or key not in actual:\n                yield f\"{path}.{key}\"\n            elif not any(\n                not list(compare(option, actual[key]))\n                for option in (accepted or {}).get(key, [])\n            ):\n                yield from compare(expected[key], actual[key], f\"{path}.{key}\")\n    elif isinstance(expected, list) and isinstance(actual, list):\n        if len(expected) != len(actual):\n            yield f\"{path} (length)\"\n        for i, (left, right) in enumerate(zip(expected, actual)):\n            yield from compare(left, right, f\"{path}[{i}]\")\n    elif type(expected) != type(actual) or expected != actual:\n        yield path\n\n\ndef main():\n    if len(sys.argv) != 3:\n        raise SystemExit(\"Usage: python3 check.py expected.json answer.json\")\n    try:\n        expected, actual = [json.loads(Path(p).read_text(encoding=\"utf-8\")) for p in sys.argv[1:]]\n        alternatives = Path(sys.argv[1]).with_name(\"accepted.json\")\n        accepted = json.loads(alternatives.read_text(encoding=\"utf-8\")) if alternatives.is_file() else {}\n    except (ValueError, OSError) as error:\n        raise SystemExit(str(error))\n    differences = list(compare(expected, actual, accepted=accepted))\n    if differences:\n        raise SystemExit(\"Different fields: \" + \", \".join(differences))\n    print(\"Pass\")\n\n\nif __name__ == \"__main__\":\n    main()\n"},{"path":"tests\/README.md","content":"Give your agent SKILL.md and one request.txt in a fresh session. Keep the expected answer aside. Save the reply as answer.json, then run this from the tests folder:\n\n    python3 check.py case-1\/expected.json answer.json\n\nEach case also has an explanation. Where accepted.json exists, the checker accepts the alternatives listed there.\n"},{"path":"tests\/case-1\/request.txt","content":"Clean the purchases. Date order is unknown. Empty prices mean missing. Pounds use a decimal point.\nReturn only the JSON specified in SKILL.md for this test.\n\ncustomer,date,price\n00123,03\/04\/2026,\n00123,2026-04-05,0\n"},{"path":"tests\/case-1\/expected.json","content":"{\n    \"rows\": [\n        {\n            \"customer\": \"00123\",\n            \"date\": \"03\/04\/2026\",\n            \"price\": null\n        },\n        {\n            \"customer\": \"00123\",\n            \"date\": \"2026-04-05\",\n            \"price\": 0\n        }\n    ],\n    \"review\": [\n        \"1.date\"\n    ]\n}\n"},{"path":"tests\/case-1\/explanation.txt","content":"The customer occurs twice. Neither the ambiguous date nor the missing price can be inferred from the second purchase.\n"},{"path":"tests\/case-2\/request.txt","content":"Use DD\/MM\/YYYY. NA is missing for price. Customer IDs are literal text.\nReturn only the JSON specified in SKILL.md for this test.\n\ncustomer,date,price\n0A1,04\/05\/2026,NA\n000,05\/05\/2026,2.50\n"},{"path":"tests\/case-2\/expected.json","content":"{\n    \"rows\": [\n        {\n            \"customer\": \"0A1\",\n            \"date\": \"2026-05-04\",\n            \"price\": null\n        },\n        {\n            \"customer\": \"000\",\n            \"date\": \"2026-05-05\",\n            \"price\": 2.5\n        }\n    ],\n    \"review\": []\n}\n"},{"path":"tests\/case-2\/explanation.txt","content":"The agreed convention resolves the ambiguous-looking dates while the identifier 000 survives.\n"},{"path":"tests\/case-3\/request.txt","content":"Clean this stock list. Treat both id and area as text. In area only, blank and N\/A mean missing. Keep the bin column unchanged.\nReturn only the JSON specified in SKILL.md for this test.\n\nid,area,bin\n009,NA,B7\n9,N\/A,B4\n8,,B2\n"},{"path":"tests\/case-3\/expected.json","content":"{\n    \"rows\": [\n        {\n            \"id\": \"009\",\n            \"area\": \"NA\",\n            \"bin\": \"B7\"\n        },\n        {\n            \"id\": \"9\",\n            \"area\": null,\n            \"bin\": \"B4\"\n        },\n        {\n            \"id\": \"8\",\n            \"area\": null,\n            \"bin\": \"B2\"\n        }\n    ],\n    \"review\": []\n}\n"},{"path":"tests\/case-3\/explanation.txt","content":"NA is a real area. Its spelling differs from the declared marker, and the two similar-looking IDs remain separate.\n"}],"is_active":true,"is_approved":false}]}]}