GrepBoard/Manuals
605 manuals ·

Split a one-cell Korean address into province, city, rest

·Tested on Claude Sonnet 5.5 · 2026-10·Test scope ↓·6 steps

Split Korean addresses in Latin letters into province, city and the rest with one Excel formula. Covers Sejong and two-word districts, checked by script.

A plain split on spaces goes wrong in three places: extra spaces between words, Sejong (a city with no municipal district, so the second word is already part of the street), and two-word districts such as Suwon-si Yeongtong-gu, where the district takes two words. This article uses Korean addresses written in Latin letters, in Korean word order, and asks for one spill formula plus a roundtrip check. Pasted-table checks of the same kind are in Convert pasted tables to CSV.

[1] Prepare the address list. Five of the 20 sample rows are shown (all 20 are in run/raw_addresses_en.txt).

sample.txt
1. Seoul Gangnam-gu Teheran-ro 1522. Seoul   Seocho-gu    Banpo-daero 589. Sejong   Dodum 6-ro 1111. Gyeonggi-do Suwon-si Yeongtong-gu Gwanggyo-jungang-ro 17020. Jeju-do Jeju-si Cheomdan-ro 242

[2] Write the prompt. It names Microsoft 365, the Sejong rule, the two-word district rule, an E2 roundtrip formula and a 20-row result table. One line forbids LET variable names that look like cell addresses. That line is there because an earlier English run on Hangul addresses (run/prompt_en.out.txt, not used in this article) wrote its variables as w1, w2 and w3. Those are also the cell addresses W1, W2 and W3, and Microsoft says a LET name cannot conflict with range syntax (LET function). That formula was not entered into Excel to confirm the error.

text
In Microsoft 365 Excel, {input_address_range} contains Korean delivery addresses written in Latin letters, in Korean word order, one address per cell. Write Excel formulas to split each address into three columns:- Column B: Province or metropolitan city (first word)- Column C: City, county or district- Column D: Remaining address (road name, building number, detail) The address data contains the following edge cases:1. Irregular spacing: some rows have two or more consecutive spaces between words.2. Sejong: the first word is "Sejong", which has no municipal district. Column C must be left blank ("") and everything after "Sejong" goes into Column D.3. Cities with non-autonomous districts: for example "Gyeonggi-do Suwon-si Yeongtong-gu ...". When word 2 ends with "-si" and word 3 ends with "-gu", combine them into Column C as "Suwon-si Yeongtong-gu", and Column D begins at word 4.4. Regular addresses: word 1 is the province, word 2 is the district, word 3 onwards is the remaining address. Requirements:- Provide one single spill formula in B2 that fills B2:D2.- Use Microsoft 365 functions such as LET, TEXTSPLIT, TRIM and HSTACK.- LET variable names must not look like cell addresses (for example do not use w1 or c2).- Provide a roundtrip formula in E2 (TEXTJOIN and EXACT) that confirms re-merging B, C and D equals the trimmed original address.- Show the split results for the following 20 sample addresses in a Markdown table (columns: Row | Original | Province | District | Remaining). [Sample 20 Addresses]{address_list}

[3] Run it with the project instructions switched off.

console
$ claude -p --model claude-sonnet-5-5 --max-turns 1 --tools "" --setting-sources "" --strict-mcp-config < run/prompt_en3.prompt.txt > run/prompt_en3.out.txt

The model's B2 formula and E2 roundtrip formula:

output
=LET(    cleanText, TRIM(A2),    parts,     TEXTSPLIT(cleanText, " "),    cnt,       COUNTA(parts),    first,     INDEX(parts, 1),    second,    IF(cnt >= 2, INDEX(parts, 2), ""),    third,     IF(cnt >= 3, INDEX(parts, 3), ""),    isSejong,  first = "Sejong",    isCityGu,  AND(RIGHT(second, 3) = "-si", RIGHT(third, 3) = "-gu"),    skipCount, IF(isSejong, 1, IF(isCityGu, 3, 2)),    district,  IF(isSejong, "", IF(isCityGu, second & " " & third, second)),    remaining, IF(cnt > skipCount, TEXTJOIN(" ", TRUE, DROP(parts, , skipCount)), ""),    HSTACK(first, district, remaining))
output
=EXACT(TEXTJOIN(" ", TRUE, B2:D2), TRIM(A2))

The model said it had not run these in Excel and had traced the table by hand. An excerpt of its table:

output
| Row | Original | Province | District | Remaining ||---|---|---|---|---|| 1 | Seoul Gangnam-gu Teheran-ro 152 | Seoul | Gangnam-gu | Teheran-ro 152 || 2 | Seoul   Seocho-gu    Banpo-daero 58 | Seoul | Seocho-gu | Banpo-daero 58 |…| 9 | Sejong   Dodum 6-ro 11 | Sejong | (blank) | Dodum 6-ro 11 || 10 | Sejong Jochiwon-eup Gunchung-gil 9 | Sejong | (blank) | Jochiwon-eup Gunchung-gil 9 || 11 | Gyeonggi-do Suwon-si Yeongtong-gu Gwanggyo-jungang-ro 170 | Gyeonggi-do | Suwon-si Yeongtong-gu | Gwanggyo-jungang-ro 170 || 12 | Gyeonggi-do Seongnam-si Bundang-gu Pangyoyeok-ro 166 | Gyeonggi-do | Seongnam-si Bundang-gu | Pangyoyeok-ro 166 |…| 16 | Gyeonggi-do Hwaseong-si Dongtanosan-ro 80 | Gyeonggi-do | Hwaseong-si | Dongtanosan-ro 80 |…| 18 | Chungcheongnam-do Yesan-gun Yesan-eup Sajik-ro 33 | Chungcheongnam-do | Yesan-gun | Yesan-eup Sajik-ro 33 |…| 20 | Jeju-do Jeju-si Cheomdan-ro 242 | Jeju-do | Jeju-si | Cheomdan-ro 242 |

The second run (run/prompt_en3_2.out.txt) gave the same Province, District and Remaining values for all 20 rows; the table differed only in how a blank district was written and in some cells wrapped in backticks. The formulas were not the same: run 2 builds the remainder with TEXTAFTER(cleaned, " ", skip) and IFERROR instead of DROP, and its E2 formula refers to the spill range as B2#. Neither run uses a variable name that looks like a cell address.

[4] Check the model's table with a script. The script does not run the formula. For each row it compares the table with the source address: the Original column must equal the source, Province + District + Remaining joined by spaces must equal the source (roundtrip), the province must be one of 17 known names, and the district must match the rule (blank for Sejong; words 2 and 3 joined if word 2 ends in -si and word 3 ends in -gu; otherwise word 2). The script recomputes that rule itself, so it cannot tell whether the rule is wrong, and it does not look at what kind of space characters were used.

run/verify_addr_en.py
import re, sys SIDO = {"Seoul", "Busan", "Daegu", "Incheon", "Gwangju", "Daejeon", "Ulsan", "Sejong", "Gyeonggi-do",        "Gangwon-do", "Chungcheongbuk-do", "Chungcheongnam-do", "Jeonbuk-do", "Jeollanam-do",        "Gyeongsangbuk-do", "Gyeongsangnam-do", "Jeju-do"}BLANK = {"", "(blank)", '""'} raw = [re.sub(r"^\d+\.\s*", "", l).strip() for l in open(sys.argv[1], encoding="utf-8") if l.strip()]rows = [[c.strip().strip("`") for c in l.strip().strip("|").split("|")] for l in open(sys.argv[2], encoding="utf-8") if l.startswith("|")]rows = [r for r in rows if len(r) == 5 and not set(r[0]) <= set("-: ")][1:]   # skip the header row bad = 0 if len(rows) == len(raw) else 1if bad:    print(f"row count mismatch: table {len(rows)}, source {len(raw)}")for no, (row, src) in enumerate(zip(rows, raw), start=1):    _, orig, prov, dist, rest = row    dist = "" if dist in BLANK else dist    w = src.split()    want = "" if w[0] == "Sejong" else (        f"{w[1]} {w[2]}" if len(w) > 2 and w[1].endswith("-si") and w[2].endswith("-gu") else w[1])    errs = []    if " ".join(orig.split()) != " ".join(w): errs.append("original column differs from source")    if " ".join(p for p in (prov, dist, rest) if p) != " ".join(w): errs.append("roundtrip mismatch")    if prov not in SIDO: errs.append("unknown province")    if dist != want: errs.append(f"district {dist!r} (expected {want!r})")    if errs:        bad += 1        print(f"BAD {no:2d}: [{prov}] [{dist}] [{rest}] <- " + ", ".join(errs))    else:        print(f"OK  {no:2d}: [{prov}] [{dist}] [{rest}]")print(f"{len(rows)} rows, {bad} errors")sys.exit(1 if bad else 0)
console
$ python run/verify_addr_en.py run/raw_addresses_en.txt run/prompt_en3.out.txtOK   1: [Seoul] [Gangnam-gu] [Teheran-ro 152]OK   2: [Seoul] [Seocho-gu] [Banpo-daero 58]…OK   9: [Sejong] [] [Dodum 6-ro 11]OK  10: [Sejong] [] [Jochiwon-eup Gunchung-gil 9]OK  11: [Gyeonggi-do] [Suwon-si Yeongtong-gu] [Gwanggyo-jungang-ro 170]OK  12: [Gyeonggi-do] [Seongnam-si Bundang-gu] [Pangyoyeok-ro 166]…OK  16: [Gyeonggi-do] [Hwaseong-si] [Dongtanosan-ro 80]…OK  20: [Jeju-do] [Jeju-si] [Cheomdan-ro 242]20 rows, 0 errors

[5] Three hand-made bad tables were tested and all exited with code 1 (not model output): run/bad_en_sejong.txt puts a road name in Sejong's district, run/bad_en_province.txt misspells a province, and run/bad_en_seongnam.txt splits Seongnam-si Bundang-gu into Seongnam-si and Bundang-gu Pangyoyeok-ro 166. The third passes the roundtrip, because joining the parts still gives the source, and is caught only by the district rule.

console
$ python run/verify_addr_en.py run/raw_addresses_en.txt run/bad_en_sejong.txt…BAD  9: [Sejong] [Dodum] [6-ro 11] <- district 'Dodum' (expected '')…20 rows, 1 errors$ python run/verify_addr_en.py run/raw_addresses_en.txt run/bad_en_seongnam.txt…BAD 12: [Gyeonggi-do] [Seongnam-si] [Bundang-gu Pangyoyeok-ro 166] <- district 'Seongnam-si' (expected 'Seongnam-si Bundang-gu')…20 rows, 1 errors

[6] Where it falls short.

  • Not run in Excel: the check above is of the model's hand-traced table. Enter the formula in a sheet and use the E2 roundtrip formula with =COUNTIF(E2:E21, FALSE) to see whether Excel produces the same table. That was not tested in this run.
  • Variable names: if an answer uses a name like w1, ask again with the "no cell-address names" line. The runs shown here did not repeat the problem, and the prompt was not tried without that line on these Latin-letter addresses.
  • Sejong's Jochiwon-eup (row 10) went to the remaining address, as rule 2 says. If you want towns in the district column, state that rule in the prompt.
  • Special spaces: neither formula here replaces non-breaking or full-width spaces, and Microsoft documents that TRIM removes only the ordinary space character (TRIM function). The sample has none, so this was not tested.
  • The -si / -gu rule matched all 20 rows here; other address shapes were not tested.

As Microsoft's Copilot guidance says, review a generated formula yourself before applying it to a whole dataset.

#excel#address#data#prompt