{"id":"data2-csv-split-address-columns","audience":"operations","category":"data","track":"data","technique":"examples","level":"intermediate","title":"Split a messy address column into a clean CSV block","free":false,"task":"A shipping export has one address column and you need separate fields. Write one CSV block (one code block) with the header original,street,city,state,zip and one row per address in the same order. Keep apartment numbers in street, write the ZIP as 5 digits, and leave a field empty if the address doesn't contain it. At most 12 words outside the code. Wrap cells that contain commas in double quotes.","materialLabel":"Addresses as exported (attached to your prompt automatically)","material":"Shipping export, column \"ship_to\" (Harborview Supply), 6 rows:\n\n1. 412 Elm St Apt 3, Dayton, OH 45402\n2. 88 Lakeshore Dr, Chicago IL 60601-1234\n3. 1600 Main Street, Springfield, MA\n4. PO Box 77, Austin, TX 78701\n5. 25 Birch Lane Unit B, Portland, OR 97201\n6. 9 Quarry Rd, Pittsburgh, PA 1521\n\nContext:\n- All addresses are in the United States.\n- A ZIP+4 (like 60601-1234) should be reduced to the 5-digit ZIP.\n- Row 3 has no ZIP in the export, and row 6's ZIP has only 4 digits, so it is incomplete and nobody knows the missing digit.\n- State must be the two-letter abbreviation as given.\n- The labels team needs one value per field; the original text goes in the first column.","rules":[{"type":"codeBlocks","count":1},{"type":"maxProseWords","max":12}],"mistakes":[{"title":"Guessing the ZIP","why":"The AI invents a ZIP for Springfield and pads the 4-digit one.","fix":"Add: \"If a ZIP is missing or incomplete, leave zip empty. Don't guess.\"","checks":["r0"]},{"title":"Dropping apartment numbers","why":"The AI moves Apt 3 into its own column or drops it.","fix":"Add: \"Keep Apt or Unit in street.\"","checks":["r1"]},{"title":"Broken CSV quoting","why":"Unquoted commas in the original shift every column.","fix":"Add: \"Put the original in double quotes. 6 rows in the same order.\"","checks":["r2"]},{"title":"Leaving the format to chance","why":"The AI picks its own length and layout unless told the exact shape.","fix":"Add: \"Put the code in exactly 1 code block. Keep the writing outside the code under 12 words.\"","checks":["codeBlocks","maxProseWords"]}],"promptHints":[{"label":"Asks for the header","patterns":["original,street","header"]},{"label":"Keeps units in street","patterns":["apt","unit","keep"]},{"label":"Handles ZIP+4","patterns":["zip\\+4","5 digits","5-digit"]},{"label":"Says no guessing","patterns":["don.t guess","leave (zip )?empty"]},{"label":"Gives the quoting rule","patterns":["double quotes","quote"]}],"hint":"Splitting messy text works when you say what to do with missing and malformed pieces.","mission":"Split this address column into fields.","musts":["One CSV block","Keep apartments in street","Missing ZIP stays empty"],"rubricLabels":["Rows 1 and 5 keep the apartment or unit in street (412 Elm St Apt 3, 25 Birch Lane Unit B) with the right city, state and 5-digit ZIP (45402, 97201)","Row 2 has ZIP 60601 (the +4 dropped), row 3 has an empty zip, and row 6 has an empty zip rather than a guessed 5-digit value","The code block is CSV with the header original,street,city,state,zip and 6 rows in the original order, with the original column quoted when it contains commas"]}