GitHub user dosubot[bot] edited a comment on the discussion: 关于电网拓扑数据导入
<!-- Answer -->
你遇到的“Make sure the primary key fields [id] are not empty, or check whether the
headers or field_mapping are configured correctly”报错,根本原因是 struct_1.json 的
edges 配置 field_mapping 写成了 `"from": "id", "to": "id"`,而不是 `"from": "from",
"to": "to"`,或者 source/target 配置写反了,或者 CSV header/数据有问题。
**请严格检查以下几点:**
1. struct_1.json 的 edges 配置必须是:
```json
"source": ["from"],
"target": ["to"],
"field_mapping": { "from": "from", "to": "to" }
```
不能有 id,不能写反 source/target。
2. power_edges_to.csv(或 edge_connected_to.csv)header 必须严格为:
```
id,from,to,label,source_label,target_label
```
没有多余空格、没有 BOM、没有隐藏字符。
3. 所有 from/to 字段都不能有空值,且和顶点 id 完全一致(无多余空格、无大小写问题、无空行)。
4. struct_1.json 的 null_values 建议只保留 ["NULL", "null"],不要加 "",否则空字符串会被判定为
null,导致 id 为空。
5. schema.groovy 的边标签 .properties() 只包含实际需要的属性(如 "source_label",
"target_label"),不要加 "id"。
**常见坑:**
- source/target 写反(比如 "source": ["to"], "target": ["from"])
- field_mapping 写成了 id
- CSV header 有隐藏字符或 BOM
- null_values 配置了空字符串
- 顶点 id 有重复或空行
**如果你已经全部按上述做了,还是报错,请贴出:**
- power_edges_to.csv 的 header 和前 2 行原始数据(不要做任何处理)
- struct_1.json 某个 edges 配置的完整内容(尤其是 source/target/field_mapping/value_mapping)
这样我可以帮你定位具体是哪一行或哪一列有问题。
只要这些全部做到,边就能正常导入且无报错,所有关系都能导入。[官方FAQ说明](https://github.com/apache/incubator-hugegraph-doc/blob/master/content/en/docs/guides/faq.md)
<!-- Dosu Comment Footer -->
*To reply, just mention
[@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fhugegraph).*
---
Share context across your team and agents. Try
[Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-tagline&utm_term=apache%2Fhugegraph).
[](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-feedback&utm_term=apache%2Fhugegraph#message_id=382f0552-e460-43fe-8327-0223fc1f9af0)
[](https://github.dosu.com/apache/hugegraph?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-learn-repo&utm_term=apache%2Fhugegraph)
[](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-add-team&utm_term=apache%2Fhugegraph)
GitHub link:
https://github.com/apache/hugegraph/discussions/2917#discussioncomment-15226420
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]