9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/tax_jp/addresses/db_builder.rb', line 9
def run(options = {})
with_database(options) do |db|
puts
prefecture_code = nil
CSV.foreach(File.join('data', '住所', 'addresses.csv')) do |line|
if prefecture_code != line[0][0..1]
prefecture_code = line[0][0..1]
puts prefecture_code
end
zip_code = line[2]
prefecture_name = line[6]
city = line[7]
section = line[8] == '以下に掲載がない場合' ? '' : line[8]
section = section.gsub(/(.*/, '')
if section.end_with?('地割)') or section.end_with?('地割')
next
end
row = [zip_code, prefecture_code, prefecture_name, city, section]
db.execute(insert_sql, row)
end
puts
end
end
|