Import List of Towns in Japan to neo4j database

Import List of Towns in Japan to neo4j database
作者: Calpa Liu
字數:1084
出版日期:September 4, 2022
更新日期:September 4, 2022

A town is contained within a district.

A town is contained within a district.

The list of towns in Japan is available in the wikipedia.

Town, Japanese, Prefecture, District, Area

For each town in towns, the town node has property: name, jp. The town is in Prefecture, and the town is also in the District.

So the cypher is quiet simple

UNWIND $towns as town
MATCH (p:Prefecture)
WHERE p.en = toLower(town.prefecture)
  OR p.en = toLower(
    replace(
      replace(town.prefecture, 'ō', 'o'),
      'Ō',
      'O'
    )
  )

MERGE (t:Town:Municipal{name: town.name})-[:IN]->(p)
SET t.en = town.en

WITH t, town
MERGE (d:District {name: town.district})
MERGE (t)-[:IN]->(d)
MERGE (m:Metric{name: 'area'})
MERGE (t)-[hm:HAS_METRIC]->(m)
SET hm.value = apoc.number.parseFloat(town.area)

Question

I would like to know which prefecture is Nishiki (錦町) located.

MATCH (t:Town)-[:IN]->(p:Prefecture)
WHERE t.en = 'Nishiki'
RETURN t, p

So Nishiki is located in the Kumamoto Prefecture.

Reference

  1. List of towns in Japan
感謝您閱讀我的文章。歡迎隨時分享你的想法。
關於 Calpa

Calpa 擅長使用 TypeScript、React.js 和 Vue.js 開發Responsive Web Design網站。

此外,Calpa 積極參與香港和台灣的開源社區,曾在2019年的香港開源大會上擔任講者,提供工作經驗和見解。此外,他也在 GitHub 上公開分享個人博客程式碼,已獲得超過300顆星星和60個分支的支持。

更多前端開發技術文章:傳送門