zipcode

package module
v0.0.0-...-df52465 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2018 License: BSD-3-Clause Imports: 9 Imported by: 1

README

GoDoc

KEN_ALL.CSVパーサ

郵便番号データを扱いやすく整形します。

Installation

go get lufia.org/pkg/japanese/zipcode

Features

  • 複数行にまたがる郵便番号を1行に結合
  • 英数字や記号をASCII文字に統一
  • 以下に掲載がない場合その他 などの文字を削除
  • 町域(ほげ、ふが)町域ほげ町域ふが に分割
  • 町域(1〜3、5番地)町域1番地町域2番地 などに分割
  • 地割対応

Documentation

Overview

KEN_ALL.CSVパーサ。

Index

Examples

Constants

View Source
const (
	// 変更なし。
	StatusNotModified Status = 0

	// 変更あり。
	StatusModified = 1

	// 廃止。
	StatusObsoleted = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	// 全国地方公共団体コード。
	Code string

	// 旧郵便番号(5桁)。
	OldZip string

	// 郵便番号(7桁)。
	Zip string

	// 都道府県名。
	Pref Name

	// 市区町村名。
	Region Name

	// 町域名。
	Town Name

	// 町域が2つ以上の郵便番号を持つ。
	IsPartialTown bool

	// 小字ごとに番地が起番されている。
	IsLargeTown bool

	// 丁目を有する町域。
	IsBlockedScheme bool

	// 1つの郵便番号で2つ以上の町域をあらわす。
	IsOverlappedZip bool

	// 更新の有無。
	Status Status

	// 更新理由。
	Reason Reason

	// 備考。このフィールドはKEN_ALL.CSVには存在しない。
	Notice string
}

郵便番号データのエントリを表す。

type Name

type Name struct {
	// 漢字表記の名前。
	Text string

	// カナ表記の名前。
	Ruby string
}

ルビ付き名前を表す。

func (Name) Equal

func (name Name) Equal(name1 Name) bool

名前が同じものかどうかを返す。

type Parser

type Parser struct {
	Error error
}

func (*Parser) Parse

func (parser *Parser) Parse(r io.Reader) <-chan *Entry

Parseは郵便番号データを流すチャネルを返す。 エラーが途中で発生した場合、チャネルはclosedになりparser.Errorにエラーをセットする。

Example
tab := []string{
	`36207,"77703","7770301","トクシマケン","ミマシ","コヤダイラ(イチハナ、イママル、オヤマ、カゴミ、カシワラ、キナカ、クワガラ、ケヤキヒラ、コビウラ、","徳島県","美馬市","木屋平(市初、今丸、尾山、カゴミ、樫原、木中、桑柄、ケヤキヒラ、小日浦、",1,0,0,0,0,0`,
	`36207,"77703","7770301","トクシマケン","ミマシ","ジジンダキ、スゲゾウ、ツエダニ、ツヅロウ、ハジコノ、ビヤガイチ、フタド、ミツギ、ミツグ、","徳島県","美馬市","地神滝、菅蔵、杖谷、葛尾、ハジコノ、ビヤガイチ、二戸、三ツ木、貢、",1,0,0,0,0,0`,
	`36207,"77703","7770301","トクシマケン","ミマシ","ミナミバリ、ムコウカシワラ)","徳島県","美馬市","南張、向樫原)",1,0,0,0,0,0`,
}
data := strings.Join(tab, "\r\n")
fin := bytes.NewBufferString(data)

var parser Parser
c := parser.Parse(fin)
var last *Entry
for entry := range c {
	last = entry
}
if parser.Error != nil {
	log.Fatal(parser.Error)
}
fmt.Println(last.Pref.Text + last.Region.Text + last.Town.Text)
Output:

徳島県美馬市木屋平向樫原

type Reason

type Reason int

更新理由を表す。

const (
	ReasonNotModified Reason = 0
)

type Status

type Status int

更新の表示。

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL