<NME> v1.js
<BEF> var gutil = require( 'gulp-util' );
var through  = require( 'through2' );
var path = require( 'path' );
var prefs = require( './prefs.json' );

module.exports = function () {
  var transform = function( file, enc, callback ) {
    var content = file.contents.toString();
    var res = JSON.parse( content );

    var postal_codes = {};
      cast: [ 'String', 'String', 'String', 'String', 'String', 'String', 'String' ]
    } ).parse();

    for ( var i = 0; i < res.length; i++ ) {
      var line = res[i];
      if ( ! prefs[line[1].trim()] ) {
        console.log( line[1].trim() );
        process.exit(1);
      }
      var data = {
        code: line[0].toString().trim(),
        prefcode: prefs[line[1]],
        ja: {
          prefecture: line[1].trim(),
          address1: line[2].replace( '　', '' ).trim(),
          address2: line[3].replace( /（.*/, '' ).replace( '　', '' ).trim()
        },
        en: {
          prefecture: line[4].trim().replace( / .+$/, '' ).capitalize(),
          address2: line.en.addr2,
                .replace( /^([A-Z]+) ([A-Z]+)$/, "$1-$2" )
                .replace( /^([A-Z]+) ([A-Z]+) ([A-Z]+) ([A-Z]+)$/, "$3-$4, $1-$2" )
                .capitalize(),
          address2: line[6].replace( / \(.*/, '' ).trim().capitalize()
        }
      };

      var file = new gutil.File( {
        cwd: __dirname,
        path: path.join( __dirname, line[0].replace( /^([0-9]{3}).*/, '$1' ),
                  line[0].replace( /.*([0-9]{4})$/, '$1' ) + '.json' ),
        contents: new Buffer( JSON.stringify( data ) + "\n" )
      } );

      this.push( file );

  return through.obj( transform );
};

<MSG> bug fix

<DFF> @@ -12,19 +12,20 @@ module.exports = function () {
       cast: [ 'String', 'String', 'String', 'String', 'String', 'String', 'String' ]
     } ).parse();
 
+    var postal_codes = {};
     for ( var i = 0; i < res.length; i++ ) {
       var line = res[i];
       if ( ! prefs[line[1].trim()] ) {
         console.log( line[1].trim() );
         process.exit(1);
       }
+
       var data = {
-        code: line[0].toString().trim(),
-        prefcode: prefs[line[1]],
         ja: {
           prefecture: line[1].trim(),
           address1: line[2].replace( '　', '' ).trim(),
-          address2: line[3].replace( /（.*/, '' ).replace( '　', '' ).trim()
+          address2: line[3].replace( /（.*/, '' ).replace( '　', '' )
+              .replace( /以下に掲載がない場合/, "" ).trim()
         },
         en: {
           prefecture: line[4].trim().replace( / .+$/, '' ).capitalize(),
@@ -32,15 +33,28 @@ module.exports = function () {
                 .replace( /^([A-Z]+) ([A-Z]+)$/, "$1-$2" )
                 .replace( /^([A-Z]+) ([A-Z]+) ([A-Z]+) ([A-Z]+)$/, "$3-$4, $1-$2" )
                 .capitalize(),
-          address2: line[6].replace( / \(.*/, '' ).trim().capitalize()
+          address2: line[6].replace( /ikanikeisaiganaibaai/i, "" ).replace( / \(.*/, '' )
+                .trim().capitalize()
         }
       };
 
+      if ( postal_codes[line[0].toString().trim()] ) {
+        postal_codes[line[0].toString().trim()].address.push( data );
+      } else {
+        postal_codes[line[0].toString().trim()] = {
+          code: line[0].toString().trim(),
+          prefcode: prefs[line[1]],
+          address: [data]
+        };
+      }
+    }
+
+    for ( var p in postal_codes ) {
       var file = new gutil.File( {
         cwd: __dirname,
-        path: path.join( __dirname, line[0].replace( /^([0-9]{3}).*/, '$1' ),
-                  line[0].replace( /.*([0-9]{4})$/, '$1' ) + '.json' ),
-        contents: new Buffer( JSON.stringify( data ) + "\n" )
+        path: path.join( __dirname, p.replace( /^([0-9]{3}).*/, '$1' ),
+                  p.replace( /.*([0-9]{4})$/, '$1' ) + '.json' ),
+        contents: new Buffer( JSON.stringify( postal_codes[p] ) + "\n" )
       } );
 
       this.push( file );

bug fix