Coder Social home page Coder Social logo

p5-parse-japanesepostalcode's Introduction

NAME

Parse::JapanesePostalCode - PostalCode Parser for 日本郵政

SYNOPSIS

use Parse::JapanesePostalCode;

my $parser = Parse::JapanesePostalCode->new( file => 'KEN_ALL.csv' );
while (my $obj = $parser->fetch_obj) {
    my @list = map { $_ ? $_ : () } ($obj->zip, $obj->pref, $obj->district, $obj->city, $obj->ward, $obj->town);
    if ($obj->has_subtown) {
        push @list, join '/', @{ $obj->subtown };
    }
    if ($obj->build) {
        my $str = $obj->build;
        $str .= $obj->floor . 'F' if $obj->floor;
        push @list, $str;
    }
}

DESCRIPTION

Parse::JapanesePostalCode is a feel good parser to parse to Postal Code files that are provided by Japan Post.

Parse::JapanesePostalCode は、日本郵政が提供している郵便番号ファイルを良い感じにパースしてくれるパーサです。

METHODS

new

create to parser instance.

read from file path.

my $parser = Parse::JapanesePostalCode->new(
    file => 'foo/bar/KEN_ALL.csv',
);

read from file handle.

my $parser = Parse::JapanesePostalCode->new(
    fh => $ken_all_fh,
);

ignore katakana_h2z.

my $parser = Parse::JapanesePostalCode->new(
    file => 'foo/bar/KEN_ALL.csv',
    katakana_h2z => 0,
);

ignore alnum_z2h.

my $parser = Parse::JapanesePostalCode->new(
    file => 'foo/bar/KEN_ALL.csv',
    alnum_z2h => 0,
);

get_line

get one line from KEN_ALL.csv.

while (my $line = $parser->get_line) {
  say $line;
}

1行読み込みます。もし

07543,"97906","9790622","フクシマケン","フタバグントミオカマチ","ケガヤ(マエカワハラ232-244、311、312、337-862バンチ","福島県","双葉郡富岡町","毛萱(前川原232〜244、311、312、337〜862番地",1,1,0,0,0,0
07543,"97906","9790622","フクシマケン","フタバグントミオカマチ","トウキョウデンリョクフクシマダイ2ゲンシリョクハツデンショコウナイ)","福島県","双葉郡富岡町","〔東京電力福島第二原子力発電所構内〕)",1,1,0,0,0,0

のように複数行に分割されていたら、良い感じに行をマージした結果を返します。

fetch_obj

get one line object from KEN_ALL.csv.

while (my $obj = $parser->fetch_obj) {
  say $obj->zip;
}

get_line で取得した行を、 Parse::JapanesePostalCode::Row でオブジェクト化したオブジェクトを返します。

AUTHOR

Kazuhiro Osawa <yappo {at} shibuya {dot} pl>

SEE ALSO

Parse::JapanesePostalCode::Row, http://www.post.japanpost.jp/zipcode/download.html

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.