<NME> v1.js
<BEF> var gutil = require( 'gulp-util' );
var through  = require( 'through2' );
var csv = require( 'comma-separated-values' );
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 = new csv( content, {
      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 = {
        prefcode: prefs[line[1]],
        ja: {
          prefecture: line[1].trim(),
          address1: line[2].replace( '　', '' ).trim(),
          address2: line[3].replace( /（.*/, '' ).replace( '　', '' )
              .replace( /以下に掲載がない場合/, "" ).trim()
        },
        en: {
          prefecture: line[4].trim().replace( / .+$/, '' ).capitalize(),
          address1: line[5].trim()
                .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( /ikanikeisaiganaibaai/i, "" ).replace( / \(.*/, '' )
                .trim().capitalize()
        }
      };

      if ( postal_codes[line[0].toString().trim()] ) {
        postal_codes[line[0].toString().trim()].data.push( data );
      } else {
        postal_codes[line[0].toString().trim()] = {
          code: line[0].toString().trim(),
          data: [data]
        };
      }
        contents: new Buffer( JSON.stringify( postal_codes[p] ) + "\n" )
      } );

      this.push( file );
    }

    return callback();
  };

  return through.obj( transform );
};

  return through.obj( transform );
};


String.prototype.capitalize = function(){
  var strs = this.toLowerCase().split( ' ' );
  for ( var i = 0; i < strs.length; i++ ) {
    strs[i] = strs[i].charAt(0).toUpperCase() + strs[i].slice(1);
  }
  return strs.join( ' ' );
}

<MSG> separates csv parser

<DFF> @@ -1,49 +1,52 @@
 var gutil = require( 'gulp-util' );
 var through  = require( 'through2' );
-var csv = require( 'comma-separated-values' );
 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 = new csv( content, {
-      cast: [ 'String', 'String', 'String', 'String', 'String', 'String', 'String' ]
-    } ).parse();
+    var res = JSON.parse( content );
 
     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() );
+      // // var postal_code = line.postal_code;
+      // // var prefecture = line.prefecture;
+      // var addr1 = line.ja.addr1;
+      // var addr2 = line.ja.addr2;
+      // var pref_en = line.en.pref;
+      // var addr1_en = line[5];
+      // var addr2_en = line[6];
+
+      if ( ! prefs[line.prefecture] ) {
+        console.log( line.prefecture );
         process.exit(1);
       }
 
       var data = {
-        prefcode: prefs[line[1]],
+        prefcode: prefs[line.prefecture],
         ja: {
-          prefecture: line[1].trim(),
-          address1: line[2].replace( '　', '' ).trim(),
-          address2: line[3].replace( /（.*/, '' ).replace( '　', '' )
-              .replace( /以下に掲載がない場合/, "" ).trim()
+          prefecture: line.prefecture,
+          address1: line.ja.addr1,
+          address2: line.ja.addr2,
+          address3: line.ja.addr3,
+          address4: line.ja.addr4
         },
         en: {
-          prefecture: line[4].trim().replace( / .+$/, '' ).capitalize(),
-          address1: line[5].trim()
-                .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( /ikanikeisaiganaibaai/i, "" ).replace( / \(.*/, '' )
-                .trim().capitalize()
+          prefecture: line.en.pref,
+          address1: line.en.addr1,
+          address2: line.en.addr2,
+          address3: line.en.addr3,
+          address4: line.en.addr4
         }
       };
 
-      if ( postal_codes[line[0].toString().trim()] ) {
-        postal_codes[line[0].toString().trim()].data.push( data );
+      if ( postal_codes[line.postal_code] ) {
+        postal_codes[line.postal_code].data.push( data );
       } else {
-        postal_codes[line[0].toString().trim()] = {
-          code: line[0].toString().trim(),
+        postal_codes[line.postal_code] = {
+          code: line.postal_code,
           data: [data]
         };
       }
@@ -65,12 +68,3 @@ module.exports = function () {
 
   return through.obj( transform );
 };
-
-
-String.prototype.capitalize = function(){
-  var strs = this.toLowerCase().split( ' ' );
-  for ( var i = 0; i < strs.length; i++ ) {
-    strs[i] = strs[i].charAt(0).toUpperCase() + strs[i].slice(1);
-  }
-  return strs.join( ' ' );
-}

separates csv parser