Prepare CSV files for Gephi

How to shape node and edge CSV files for Gephi import: required columns, separators, encoding, edge direction, and checks that keep your data intact.

Gephi can build a network directly from spreadsheet-style text files, but only when the columns, separator and encoding match what its importer expects. This review covers what the Gephi CSV format requires, what converting between CSV, TSV and spreadsheet exports changes in your data, and how to check that the result still means what you intended.

Is CSV the right way to get data into Gephi?

For most people starting from a spreadsheet, database export or script output, CSV is the most practical route. It is plain text, almost every tool can produce it, and you can inspect it in any editor before importing. The decisive tradeoff is that CSV carries no built-in type information or graph structure. Gephi has to infer which column is an identifier, which columns describe edges, and whether a value is a number or a string, and small formatting differences can change those inferences.

Consider a graph-specific format such as GEXF or GraphML instead when you need to preserve node positions, colors, sizes, typed attributes or time-based data between sessions or tools. Those formats store the graph and its metadata together, while CSV only stores tables. If your data already lives in one of those formats, converting it to CSV usually loses information rather than adding convenience.

What the Gephi CSV format expects

The spreadsheet importer works with two kinds of table: a nodes table and an edges table. Gephi recognizes certain column names and treats them specially; other columns are imported as attributes.

Table | Column | Role
Nodes | Id | Unique identifier for each node; edges refer to nodes by this value
Nodes | Label | Display name shown in the graph; can differ from Id
Edges | Source | Id of the node where the edge starts
Edges | Target | Id of the node where the edge ends
Edges | Type | Directed or Undirected, per edge
Edges | Weight | Numeric strength of the edge
Either | Any other column | Imported as a node or edge attribute

A minimal pair of files might look like the following. Column names are matched by the importer, so keep the capitalization shown and avoid stray spaces in the header row.

nodes.csv
Id,Label,Group
1,Alice,Research
2,Bob,Design
3,"Chen, Wei",Research

edges.csv
Source,Target,Type,Weight
1,2,Directed,3
2,3,Undirected,1
3,1,Directed,2

Note the quotes around "Chen, Wei". Because the label contains a comma, it must be quoted so the comma is read as part of the value rather than as a column break. An edges table can be imported on its own; the import dialog generally offers to create any nodes that appear in Source or Target but not in a nodes table. Importing nodes first, then appending edges to the same workspace, gives you control over labels and attributes.

Gephi also accepts adjacency-list and matrix layouts through its general file-open route, using a semicolon-separated layout. Those are less common and more fragile for anything beyond small graphs, so the node-and-edge table approach is the one to default to.

What converting or cleaning the file actually changes

Most preparation steps change stored characters, not just how the file looks. That distinction matters: two files can display identically in a spreadsheet and still import differently because of invisible differences in separators, quotes or byte encoding.

  • Separator conversion: Turning TSV into CSV replaces tab characters with commas. Any value that already contains a comma then needs quoting, or it will split into extra columns. Going the other way, a value containing a tab will break a TSV file. Gephi's import dialog lets you choose comma, semicolon, tab or space, so you can often import TSV directly without converting it.
  • Quoting: A correct converter wraps fields that contain the separator, a double quote or a line break in double quotes, and doubles any quote characters inside them. A naive find-and-replace does not do this.
  • Encoding: Non-ASCII names, accented letters and non-Latin scripts survive only if the file's encoding matches the one selected at import. UTF-8 is the safest choice. Some spreadsheet programs add an invisible byte-order mark at the start of a UTF-8 file; if Gephi does not recognize your first column header, this is worth checking.
  • Spreadsheet reformatting: Saving through a spreadsheet can strip leading zeros from identifiers, convert long numbers to scientific notation, or turn identifier-like codes into dates. Any of these silently breaks the link between node Ids and edge Source and Target values.
  • Decimal separators: In locales that use a comma as the decimal mark, weights such as 0,5 are typically paired with semicolon-separated files. If the importer reads these as text rather than numbers, weight-based layouts and statistics will not use them. The import dialog lets you set column types; confirm Weight is numeric.

Reverse and mirror: two terms that mean different things here

In general text tools, reversing means flipping the order of characters or words, and mirroring means producing visually flipped glyphs. Neither belongs in a Gephi file. In network data, reversing usually means swapping Source and Target so every edge points the other way, and mirroring usually means adding the opposite-direction copy of each edge.

These operations change meaning. Swapping columns in a directed graph turns "A cites B" into "B cites A," which alters in-degree, out-degree and any direction-sensitive metric. Adding mirrored copies to represent an undirected relationship can double-count edges or inflate weights; marking those edges as Undirected in the Type column is usually the cleaner option. Before applying either operation, decide whether direction carries meaning in your data.

Will the file stay readable and usable after sharing?

A well-formed CSV is plain text, so it copies, diffs and versions cleanly, and anyone can open it without Gephi. The risks come from what tools do to it in transit. Pasting CSV content into an email, chat or document can convert straight quotes to curly quotes, collapse tabs into spaces, or wrap long lines, any of which can corrupt the structure. Sharing the file as an attachment is more reliable than pasting its contents.

Labels deserve particular care. Decorative Unicode lookalike letters, mirrored glyphs or reversed strings may display in Gephi, but they are different characters from ordinary text. They hinder searching and filtering inside Gephi, can break matching against other datasets, and are likely to be read poorly or not at all by screen readers when the graph or exported labels reach other people. Keep Id and Label values in ordinary text and apply visual styling through Gephi's appearance settings instead.

Mixed right-to-left and left-to-right text in labels is valid data, but how it displays depends on the rendering environment, and punctuation or numbers near script boundaries may appear reordered. If accurate display matters, check a sample of such labels after import and in any exported image or file, rather than assuming one correct rendering holds everywhere.

A short checklist before importing

  • Header row uses Id and Label for nodes, and Source and Target for edges, with no trailing spaces.
  • Every Source and Target value matches an Id exactly, including case and leading zeros.
  • Values containing the separator, quotes or line breaks are properly quoted.
  • The file is saved as UTF-8, and the same encoding is selected in the import dialog.
  • Weight and other numeric columns are assigned a numeric type during import.
  • Edge direction is set deliberately, either per edge in Type or as the graph default.
  • A small sample imports correctly before you load the full dataset.

Limits of this review

No test results, version-specific measurements or tool comparisons were supplied for this article, so the guidance above reflects Gephi's documented import conventions and general CSV principles rather than verified observations. Dialog wording, default options and handling of edge cases such as byte-order marks or locale-specific numbers can differ between Gephi releases. The most dependable check is to import a small representative sample in your own version and confirm that node counts, edge counts, labels and attribute types match your source data.