Skip to main content

Convert Korean ZIP code to address

Project description

KoZIP

Python library for converting Korean ZIP code to address

우편번호를 (도로명)주소로 변환해 주는 파이썬 라이브러리입니다. 현 우편번호(5자리), 구 우편번호(6자리) 모두 사용 가능합니다.

본 라이브러리는 우체국 홈페이지에 고시된 정보를 바탕으로 만들어졌습니다.

우편번호 고시일자 다운로드 링크
현 우편번호 (5자리) 2021.11.03. 다운로드
구 우편번호 (6자리) 2015.08.27. 다운로드

Quick Start

from kozip import KoZip

kozip = KoZIP()

kozip.ZIPtoAddr("08826", depth="full")
# 출력 :
# ['서울특별시 관악구 관악로 1 (신림동)']

kozip.ZIPtoAddr("16419", depth="full")
# 출력 :
# ['경기도 수원시 장안구 서부로 2066 (천천동)',
#  '경기도 수원시 장안구 일월로90번길 19 (천천동)',
#  '경기도 수원시 장안구 일월로90번길 7 (천천동)']

Environment

  • Python 3 이상

How to install

pip install kozip

Methods

KoZIP.ZIPtoAddr(zipcode, depth, format)

우편번호를 입력받아 주소로 변환하는 메소드

  • zipcode : 우편번호

    • 현 우편번호(5자리), 구 우편번호(6자리) 모두 사용 가능
    • 문자열 형태(str)로 입력해도 되고, 숫자 형태(int)로 입력해도 된다(단, 0으로 시작하는 우편번호는 숫자 형식으로 입력할 수 없다).
    • 구 우편번호의 경우, "123-456", "123456" 형태로 모두 사용 가능
  • depth : [Optional(default: 2)] 출력될 주소의 깊이

    depth 사용 가능한 값 설명
    1 1, "1", "시도" 시도 단위까지 출력
    2 2, "2", "시군구" 시군구 단위까지 출력. 기본값
    3 3, "3", "도로명" 도로명 단위까지 출력
    4 4, "4", "full" 도로명 단위에 추가 정보(읍면동, 리 정보)까지 출력
  • format : [Optional(default: "string")] 출력 형식

    format 사용 가능한 값 설명
    문자열 "string" 문자열 형태로 출력. 기본값
    리스트 "list" (depth 값과 같은 길이의) 리스트 형태로 출력
format
문자열 리스트
depth 1
['경기도']
[['경기도']]
2
['경기도 수원시 장안구']
[['경기도', '수원시 장안구']]
3
['경기도 수원시 장안구 서부로 2066', 
 '경기도 수원시 장안구 일월로90번길 19', 
 '경기도 수원시 장안구 일월로90번길 7']
[['경기도', '수원시 장안구', '서부로 2066'],
 ['경기도', '수원시 장안구', '일월로90번길 19'],
 ['경기도', '수원시 장안구', '일월로90번길 7']]
4
['경기도 수원시 장안구 서부로 2066 (천천동)',
 '경기도 수원시 장안구 일월로90번길 19 (천천동)',
 '경기도 수원시 장안구 일월로90번길 7 (천천동)']
[['경기도', '수원시 장안구', '서부로 2066 (천천동)'],
 ['경기도', '수원시 장안구', '일월로90번길 19 (천천동)'],
 ['경기도', '수원시 장안구', '일월로90번길 7 (천천동)']]

KoZIP.maskedZIPtoAddr(masked_zipcode, masked_letter, depth, format)

마스킹 처리된 우편번호를 입력받아 주소로 변환하는 메소드

  • masked_zipcode : 마스킹 처리된 우편번호

    • 현 우편번호(5자리)만 사용 가능
    • 길이 5인 문자열 형태(str)로만 입력해야 함
    • 오직 한 종류의 마스킹 문자(masked_letter)로만 마스킹 되어있어야 함
  • masking_letter : [Optional(default: *)] 마스킹 문자

    • 길이 1인 문자열 형태로 입력해야 함
  • depth : [Optional(default: 1)] 출력될 주소의 깊이

    depth 사용 가능한 값 설명
    1 1, "1", "시도" 시도 단위까지 출력
    2 2, "2", "시군구" 시군구 단위까지 출력. 기본값
    3 3, "3", "도로명" 도로명 단위까지 출력
    4 4, "4", "full" 도로명 단위에 추가 정보(읍면동, 리 정보)까지 출력
  • format : [Optional(default: "string")] 출력 형식

    format 사용 가능한 값 설명
    문자열 "string" 문자열 형태로 출력. 기본값
    리스트 "list" (depth 값과 같은 길이의) 리스트 형태로 출력
from kozip import KoZip

kozip = KoZIP()

kozip.maskedZIPtoAddr("08***")
# 출력 :
# ['서울특별시']

kozip.maskedZIPtoAddr("164??", masking_letter="?", depth=2, format="list")
# 출력 :
# [ ['경기도', '수원시 권선구'],
#   ['경기도', '수원시 팔달구'],
#   ['경기도', '수원시 영통구'],
#   ['경기도', '수원시 장안구'] ]

kozip.maskedZIPtoAddr("x0x01", masking_letter="x")
# 출력 :
# ['경기도', '경상남도', '세종특별자치시', '경상북도']

Changelog

v1.0

  • 최초 버전
  • KoZIP.ZIPtoAddr(zipcode, depth, format) 메서드 추가

v1.1

  • KoZIP.maskedZIPtoAddr(masked_zipcode, masked_letter, depth, format) 메서드 추가
  • Lazy Loading 구현
    • 이제 실제 데이터를 사용할 때 데이터를 로드함
    • 사용하지 않는 데이터까지 모두 로드하지 않아, 객체 생성 속도가 빨라짐

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kozip-1.1.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kozip-1.1.0-py3-none-any.whl (44.2 MB view details)

Uploaded Python 3

File details

Details for the file kozip-1.1.0.tar.gz.

File metadata

  • Download URL: kozip-1.1.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for kozip-1.1.0.tar.gz
Algorithm Hash digest
SHA256 fb1c21ad238cdb3b027c52a6a5361cfa58dbe02da72a736be59eb55a0f6227b6
MD5 3424880df6b71ce48723f36fa5ccc009
BLAKE2b-256 93bb29312d1908046d8274d41f7f2a8573fcdce34eebbad5e0483c88bd771627

See more details on using hashes here.

File details

Details for the file kozip-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: kozip-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 44.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for kozip-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f716ae63e8a46fa7de6b8a9d1c111f2dc9743eeb5fa2ca40885ae1e56bef2e50
MD5 70fb58afa075bd3ed11a13621473a677
BLAKE2b-256 f250047369ef46b6f83efa56da5d3fe89e9b59396f82b9f1e80359e1f9df0386

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page