Created
January 19, 2021 10:08
-
-
Save j416dy/e75e23eb974f596cbb987227ee91a289 to your computer and use it in GitHub Desktop.
KEN_ALL_read.pl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
open(A,"KEN_ALL_utf8.csv"); | |
#適当にKEN_ALLを詰め直すだけの奴。変数名とか色々適当なので好きなように変える前提。京都市関連のデータでしか試してない | |
my $kk = 0; | |
my $_tmp = ""; | |
foreach(<A>){ | |
chomp; | |
#26101,"60101","6010132","キョウトフ","キョウトシキタク","オノナカノチョウ","京都府","京都市北区","小野中ノ町",0,0,0,0,0,0 | |
my ($a,$b,$c,$y1,$y2,$y3,$ken,$ku,$cho) = split(/[",]+/); | |
#かっこ開始 | |
if($cho =~ /(/){ | |
if($cho =~ /)/){#その場で閉じるやつはそのまま。 | |
$kk = 0; | |
}else{ | |
$kk = 1;#括弧内部フラグ | |
$_tmp = $cho; | |
next; #次の行にまわす | |
} | |
} | |
#かっこの次行以降 | |
if($kk){ | |
$_tmp .= $cho; #追加 | |
#この行で終わりなら$choに詰め終わり出し | |
if($cho =~ /)/){ | |
$cho = $_tmp; | |
$_tmp = ""; | |
$kk = 0; | |
}else{ | |
#終わらなかったら次行回し | |
next; | |
} | |
} | |
print $ku."\t".$cho."\n"; | |
} | |
close(A); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment