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 日常幫助客戶構建一站式網站應用,手機應用,雲端架構

2023 年 9 月,Calpa 應邀出席韓國 Korea Blockchain Week 2023,新加坡 TOKEN 2049。十二月份,Calpa 將參加 Taipei Blockchain Week Hackathon。

Calpa 擅長運用各種前沿技術,包括 TypeScript、React.js 和 Vue.js,開發具有 Responsive Web Design 的網站。另外,他透過運用 aws-cdk 和 TypeScript 技術的融合,實現了基於雲端的「基礎即代碼」(Infrastructure as Code)部署策略,建立了多套高效且具有可伸縮性的全端架構。

同時,Calpa 積極參與各個社群,活躍於香港和台灣的開源社區,分享前沿知識。他曾在 2019 年的香港開源大會中擔任重要講者,為聽眾提供寶貴的工作經驗和深刻見解。此外,Calpa 在 GitHub 上公開分享了個人博客程式碼,已獲得超過 300 顆星星和 60 個分支。