Skip to content

CSV edge list

Simplest format. One edge per row; nodes are derived from the set of source / target ids. No per-node properties — use CSV pair if you need those.

edges.csv
source,target,weight
alice,bob,0.8
bob,carol,1.2
alice,carol,0.5

Download example

TSV works identically — save with tab separators and rename to .tsv.

Headers are case-insensitive. Only the four columns below are read; any others are dropped silently.

ColumnRequiredNotes
sourceyesNode id (any non-empty string).
targetyesNode id.
weightnoParsed as a number. Non-numeric values are dropped with a warning; the edge still loads without a weight.
pandas_to_edges_csv.py
# edges_df has whatever columns your pipeline produced; rename to Knotviz's
# required column names, keep weight if you have it, drop everything else.
(edges_df
.rename(columns={"src": "source", "dst": "target", "w": "weight"})
[["source", "target", "weight"]]
.to_csv("edges.csv", index=False))
pg_to_edges_csv.sh
psql -d mydb -c "\copy (
SELECT source_id AS source, target_id AS target, weight
FROM edges
) TO 'edges.csv' CSV HEADER"
nx_to_edges_csv.py
import csv, networkx as nx
with open("edges.csv", "w", newline="") as f:
w = csv.writer(f)
w.writerow(["source", "target", "weight"])
for u, v, data in G.edges(data=True):
w.writerow([u, v, data.get("weight", 1)])

Save As → CSV (UTF-8). Headers must include source and target. An optional weight column works as-is.

  • No per-node properties. The edge list can’t attach age, community, tags, etc. to nodes. If you need that, switch to CSV pair.
  • Typed headers don’t apply here. Writing weight:number or age:number won’t parse the way it does in CSV pair — the column name is checked literally, and anything that isn’t one of source/target/weight is ignored.
  • Nodes are auto-created from every id appearing in source or target. You can’t “pre-declare” a node — if you want isolated nodes (with no edges), use CSV pair or JSON.
  • Quoted cells follow RFC 4180 — commas and newlines inside "..." are preserved.
  • UTF-8 only. A BOM (Excel’s default when exporting UTF-8) is handled automatically.