GitHub user dosubot[bot] added a comment to the discussion: 关于电网拓扑数据导入

<!-- Answer -->
你的理解是对的,struct.json 里所有 "edges" 的 path 字段都可以指向同一个 edge_connected_to.csv 文件,只要 
field_mapping、source、target 配置和顶点主键字段一致即可。每个 edgeLabel 的配置会从这个文件读取数据,通过 
value_mapping 或 selected 过滤出当前 edgeLabel 需要的边类型,无需拆分多个 CSV 文件,官方文档和社区案例都推荐这种做法 
[参考](https://github.com/apache/incubator-hugegraph-doc/blob/master/content/cn/docs/quickstart/toolchain/hugegraph-loader.md)
 [案例](https://github.com/apache/incubator-hugegraph/issues/2749)。

举例:假设 edge_connected_to.csv 结构如下:

```
id,from,to,label
edge_1,BDZ-3002,XLD-3445,CONNECTED_TO
edge_2,XLD-3445,HWX-3087,CONNECTED_TO
...
```

struct.json 里可以这样写(以 LineSegment2LineSegment 为例):

```json
{
  "label": "LineSegment2LineSegment",
  "source": ["from"],
  "target": ["to"],
  "input": {
    "type": "file",
    "path": "/loader/power_data/edge_connected_to.csv",
    "format": "CSV",
    "header": ["id", "from", "to", "label"]
  },
  "field_mapping": {
    "from": "id",
    "to": "id"
  },
  "selected": ["from", "to"],
  "value_mapping": {
    "label": {
      "CONNECTED_TO": "LineSegment2LineSegment"
    }
  }
}
```

如果你有多个 edgeLabel(比如 Substation2LineSegment、LineSegment2StationHouse 等),每个 
edgeLabel 都写一段类似配置,path 都指向同一个 CSV 文件,只需用 value_mapping 或 selected 过滤出对应类型的边即可。

注意事项:
- field_mapping 的 from/to 要和顶点主键字段一致(比如都是 id)。
- value_mapping 里的 "label" 字段要和 CSV 里的 label 列内容对应。
- 如果 CSV 没有区分类型的字段,建议加一列 type 或 label,便于后续扩展和维护。
- 如果只用一个 edgeLabel(比如 CONNECTED_TO),那只需配置一次即可。

如需具体 struct.json 配置模板或遇到导入问题,可以把你的 struct.json 发出来,我可以帮你检查。


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/19a20f72-cd4a-44c7-ac5f-7e5826be3945?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/19a20f72-cd4a-44c7-ac5f-7e5826be3945?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/19a20f72-cd4a-44c7-ac5f-7e5826be3945?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/19a20f72-cd4a-44c7-ac5f-7e5826be3945?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/19a20f72-cd4a-44c7-ac5f-7e5826be3945?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/19a20f72-cd4a-44c7-ac5f-7e5826be3945?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/19a20f72-cd4a-44c7-ac5f-7e5826be3945?feedback_type=other)</sup>

[![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/e5e246fa-a522-4d8a-ab3c-e2588b5b501b/ask?utm_source=github)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=%E4%BD%A0%E7%9A%84%E7%90%86%E8%A7%A3%E6%98%AF%E5%AF%B9%E7%9A%84%EF%BC%8Cstruct.json%20%E9%87%8C%E6%89%80%E6%9C%89%20%22edges%22%20%E7%9A%84%20path%20%E5%AD%97%E6%AE%B5%E9%83%BD%E5%8F%AF%E4%BB%A5%E6%8C%87%E5%90%91%E5%90%8C%E4%B8%80%E4%B8%AA%20edge_connected_to.csv%20%E6%96%87%E4%BB%B6%EF%BC%8C%E5%8F%AA%E8%A6%81%20field_mapping%E3%80%81source%E3%80%81target%20%E9%85%8D%E7%BD%AE%E5%92%8C%E9%A1%B6%E7%82%B9%E4%B8%BB%E9%94%AE%E5%AD%97%E6%AE%B5%E4%B8%80%E8%87%B4%E5%8D%B3%E5%8F%AF%E3%80%82%E6%AF%8F%E4%B8%AA%20edgeLabel%20%E7%9A%84%E9%85%8D%E7%BD%AE%E4%BC%9A%E4%BB%8E%E8%BF%99%E4%B8%AA%E6%96%87%E4%BB%B6%E8%AF%BB%E5%8F%96%E6%95%B0%E6%8D%AE%EF%BC%8C%E9%80%9A%E8%BF%87%20value_mapping%20%E6%88%96%20selected%20%E8%BF%87%E6%BB%A4%E5%87%BA%E5%BD%93%E5%89%8D%20edgeLabe
 
l%20%E9%9C%80%E8%A6%81%E7%9A%84%E8%BE%B9%E7%B1%BB%E5%9E%8B%EF%BC%8C%E6%97%A0%E9%9C%80%E6%8B%86%E5%88%86%E5%A4%9A%E4%B8%AA%20CSV%20%E6%96%87%E4%BB%B6%EF%BC%8C%E5%AE%98%E6%96%B9%E6%96%87%E6%A1%A3%E5%92%8C%E7%A4%BE%E5%8C%BA%E6%A1%88%E4%BE%8B%E9%83%BD%E6%8E%A8%E8%8D%90%E8%BF%99%E7%A7%8D%E5%81%9A%E6%B3%95%20%5B%E5%8F%82%E8%80%83%5D%28https%3A//github.com/apache/incubator-hugegraph-doc/blob/master/content/cn/docs/quickstart/toolchain/hugegraph-loader.md%29%20%5B%E6%A1%88%E4%BE%8B%5D%28https%3A//github.com/apache/incubator-hugegraph/issues/2749%29%E3%80%82%0A%0A%E4%B8%BE%E4%BE%8B%EF%BC%9A%E5%81%87%E8%AE%BE%20edge_connected_to.csv%20%E7%BB%93%E6%9E%84%E5%A6%82%E4%B8%8B%EF%BC%9A%0A%0A%60%60%60%0Aid%2Cfrom%2Cto%2Clabel%0Aedge_1%2CBDZ-3002%2CXLD-3445%2CCONNECTED_TO%0Aedge_2%2CXLD-3445%2CHWX-3087%2CCONNECTED_TO%0A...%0A%60%60%60%0A%0Astruct.json%20%E9%87%8C%E5%8F%AF%E4%BB%A5%E8%BF%99%E6%A0%B7%E5%86%99%EF%BC%88%E4%BB%A5%20LineSegment2LineSegment%20%E4%B8%BA%E4%BE%8B%EF%BC%89%EF%BC%9A%0A%0A%60%60
 
%60json%0A%7B%0A%20%20%22label%22%3A%20%22LineSegment2LineSegment%22%2C%0A%20%20%22source%22%3A%20%5B%22from%22%5D%2C%0A%20%20%22target%22%3A%20%5B%22to%22%5D%2C%0A%20%20%22input%22%3A%20%7B%0A%20%20%20%20%22type%22%3A%20%22file%22%2C%0A%20%20%20%20%22path%22%3A%20%22/loader/power_data/edge_connected_to.csv%22%2C%0A%20%20%20%20%22format%22%3A%20%22CSV%22%2C%0A%20%20%20%20%22header%22%3A%20%5B%22id%22%2C%20%22from%22%2C%20%22to%22%2C%20%22label%22%5D%0A%20%20%7D%2C%0A%20%20%22field_mapping%22%3A%20%7B%0A%20%20%20%20%22from%22%3A%20%22id%22%2C%0A%20%20%20%20%22to%22%3A%20%22id%22%0A%20%20%7D%2C%0A%20%20%22selected%22%3A%20%5B%22from%22%2C%20%22to%22%5D%2C%0A%20%20%22value_mapping%22%3A%20%7B%0A%20%20%20%20%22label%22%3A%20%7B%0A%20%20%20%20%20%20%22CONNECTED_TO%22%3A%20%22LineSegment2LineSegment%22%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A%60%60%60%0A%0A%E5%A6%82%E6%9E%9C%E4%BD%A0%E6%9C%89%E5%A4%9A%E4%B8%AA%20edgeLabel%EF%BC%88%E6%AF%94%E5%A6%82%20Substation2LineSegment%E3%80%81LineSegme
 
nt2StationHouse%20%E7%AD%89%EF%BC%89%EF%BC%8C%E6%AF%8F%E4%B8%AA%20edgeLabel%20%E9%83%BD%E5%86%99%E4%B8%80%E6%AE%B5%E7%B1%BB%E4%BC%BC%E9%85%8D%E7%BD%AE%EF%BC%8Cpath%20%E9%83%BD%E6%8C%87%E5%90%91%E5%90%8C%E4%B8%80%E4%B8%AA%20CSV%20%E6%96%87%E4%BB%B6%EF%BC%8C%E5%8F%AA%E9%9C%80%E7%94%A8%20value_mapping%20%E6%88%96%20selected%20%E8%BF%87%E6%BB%A4%E5%87%BA%E5%AF%B9%E5%BA%94%E7%B1%BB%E5%9E%8B%E7%9A%84%E8%BE%B9%E5%8D%B3%E5%8F%AF%E3%80%82%0A%0A%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9%EF%BC%9A%0A-%20field_mapping%20%E7%9A%84%20from/to%20%E8%A6%81%E5%92%8C%E9%A1%B6%E7%82%B9%E4%B8%BB%E9%94%AE%E5%AD%97%E6%AE%B5%E4%B8%80%E8%87%B4%EF%BC%88%E6%AF%94%E5%A6%82%E9%83%BD%E6%98%AF%20id%EF%BC%89%E3%80%82%0A-%20value_mapping%20%E9%87%8C%E7%9A%84%20%22label%22%20%E5%AD%97%E6%AE%B5%E8%A6%81%E5%92%8C%20CSV%20%E9%87%8C%E7%9A%84%20label%20%E5%88%97%E5%86%85%E5%AE%B9%E5%AF%B9%E5%BA%94%E3%80%82%0A-%20%E5%A6%82%E6%9E%9C%20CSV%20%E6%B2%A1%E6%9C%89%E5%8C%BA%E5%88%86%E7%B1%BB%E5%9E%8B%E7%9A%84%E5%AD%97%E6%AE%B5%EF%BC%8C
 
%E5%BB%BA%E8%AE%AE%E5%8A%A0%E4%B8%80%E5%88%97%20type%20%E6%88%96%20label%EF%BC%8C%E4%BE%BF%E4%BA%8E%E5%90%8E%E7%BB%AD%E6%89%A9%E5%B1%95%E5%92%8C%E7%BB%B4%E6%8A%A4%E3%80%82%0A-%20%E5%A6%82%E6%9E%9C%E5%8F%AA%E7%94%A8%E4%B8%80%E4%B8%AA%20edgeLabel%EF%BC%88%E6%AF%94%E5%A6%82%20CONNECTED_TO%EF%BC%89%EF%BC%8C%E9%82%A3%E5%8F%AA%E9%9C%80%E9%85%8D%E7%BD%AE%E4%B8%80%E6%AC%A1%E5%8D%B3%E5%8F%AF%E3%80%82%0A%0A%E5%A6%82%E9%9C%80%E5%85%B7%E4%BD%93%20struct.json%20%E9%85%8D%E7%BD%AE%E6%A8%A1%E6%9D%BF%E6%88%96%E9%81%87%E5%88%B0%E5%AF%BC%E5%85%A5%E9%97%AE%E9%A2%98%EF%BC%8C%E5%8F%AF%E4%BB%A5%E6%8A%8A%E4%BD%A0%E7%9A%84%20struct.json%20%E5%8F%91%E5%87%BA%E6%9D%A5%EF%BC%8C%E6%88%91%E5%8F%AF%E4%BB%A5%E5%B8%AE%E4%BD%A0%E6%A3%80%E6%9F%A5%E3%80%82)&nbsp;[![Join
 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20
 
solve%20this%20issue!&url=https%3A//github.com/apache/incubator-hugegraph/discussions/2917)

GitHub link: 
https://github.com/apache/incubator-hugegraph/discussions/2917#discussioncomment-15193586

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to