Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

住所一覧を sqlite3 の db に出力するように変更 #121

Merged
merged 7 commits into from
Sep 29, 2022

Conversation

champierre
Copy link
Contributor

@champierre champierre commented Sep 21, 2022

latest.csv の住所の並び番が以下の通り変更となります。

  1. 都道府県コード 昇順
  2. 市区町村コード 昇順
  3. 大字町丁目名カナ 昇順
  4. 小字・通称名 昇順

例えば都道府県コードが同じ住所同士であれば、市区町村コード 昇順に、市区町村コードも同じであれば、大字町丁目名カナ 昇順に、大字町丁目名カナまでも同じであれば、小字・通称名 昇順に並びます。

また、sqlite3 コマンドの csv 出力機能を使うことにしたため、以下のとおり、各項目をダブルクオーテーションで囲むルールが一部変更になっています。

変更前

'"01","北海道","ホッカイドウ","HOKKAIDO","01632","河東郡士幌町","カトウグンシホロチョウ","KATO GUN SHIHORO CHO","字士幌仲通",,,,43.168944,143.246195'

変更後

'01,"北海道","ホッカイドウ",HOKKAIDO,01632,"河東郡士幌町","カトウグンシホロチョウ","KATO GUN SHIHORO CHO","字士幌仲通","","","",43.168944,143.246195'

新しいルールは以下の通りです。

  • 都道府県名、都道府県名カナ、市区町村名、市区町村名カナ、大字町丁目名、大字町丁目名カナ、小字・通称名のように漢字またはカタカナが使用されている項目は、ダブルクオーテーションで囲む。
  • 都道府県コード、市区町村コード、緯度、経度のように数字のみが使用されている項目は、ダブルクオーテーションで囲まない。
  • 都道府県名ローマ字、市区町村名ローマ字、大字町丁目名ローマ字のようにアルファベットおよび数字が使用されている項目の場合、スペースが含まれている場合はダブルクオーテーションで囲み、スペースがひとつも含まれていない場合はダブルクオーテーションで囲まない。
  • 値がない項目の場合、いままでは ,, のようにカンマが続いていたが、今後は ,"", のようにダブルクオーテーションで空欄を囲む形式になります。

@champierre champierre force-pushed the issue_118 branch 5 times, most recently from 09673a4 to 2174042 Compare September 23, 2022 03:02
@keichan34
Copy link
Member

latest.dbはバイナリで、これは変更入るともう一つ同じファイルが入りそうな気がするのでsqliteのデータベースをgitignoreして、リリースなどのfileとしてアップロードするだけでいいかなと思いますが、いかがでしょう。。?

@champierre
Copy link
Contributor Author

champierre commented Sep 26, 2022

5f1185e で latest.db を削除しました。 @keichan34

Copy link
Member

@keichan34 keichan34 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございました!

@@ -14,34 +14,34 @@ describe('latest.csvのテスト', () => {

it('一行目のデータを確認する', () => {
data = lines[1]
expect(data).to.equal('"20","長野県","ナガノケン","NAGANO KEN","20201","長野市","ナガノシ","NAGANO SHI","青木島二丁目","アオキジマ 2","AOKIJIMA 2",,36.617509,138.18148')
expect(data).to.equal('01,"北海道","ホッカイドウ",HOKKAIDO,01101,"札幌市中央区","サッポロシチュウオウク","SAPPORO SHI CHUO KU","旭ケ丘一丁目","アサヒガオカ 1","ASAHIGAOKA 1","",43.04223,141.319722')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@champierre ありがとうございます。都道府県コード・市区町村コードはできればクオーテーションで囲まれたままの方がいいと思うのですが、いかがでしょう?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@champierre 言及されてましたね、すみません。コメントを読み飛ばしてしまっていました。
CSV パースした時って、これらの都道府県コード・市区町村コードは数字型になってしまうでしょうか?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

それとも型は、csv パーサーで指定されてないとあんまり関係ないですかね?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://www.npmjs.com/package/sqlite-to-csv を sqlite3 の代わりに使うのを試してみます。

Copy link
Contributor Author

@champierre champierre Sep 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ライブラリは使わず以下のリンク先の部分で、CSVの形式をいままでのものに維持するようにしました。 @kamataryo

lib/export-to-csv.js
https://github.com/geolonia/japanese-addresses/pull/121/files#diff-eb6b3f0173dc22ded1459e734e13dea4578bc3dd0d3e69ebfb507593bedbec64R9

Copy link
Contributor

@kamataryo kamataryo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます!

@champierre champierre merged commit 8348135 into develop Sep 29, 2022
@champierre champierre deleted the issue_118 branch September 29, 2022 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants