Code Documentation 3.5
Social Network Visualizer
Loading...
Searching...
No Matches
TableImport Namespace Reference

Free functions that parse tabular files (CSV / JSON) into an in-memory ParsedTable that can be fed to Graph::vertexAttributesImport() or Graph::edgeAttributesImport(). More...

Classes

struct  ParsedTable
 In-memory representation of a parsed tabular file. More...
 

Functions

static QStringList parseCSVLine (const QString &line)
 
ParsedTable fromCSV (const QString &filePath)
 Parses a CSV file at filePath into a ParsedTable.
 
ParsedTable fromJSON (const QString &filePath)
 Parses a JSON file at filePath into a ParsedTable.
 

Detailed Description

Free functions that parse tabular files (CSV / JSON) into an in-memory ParsedTable that can be fed to Graph::vertexAttributesImport() or Graph::edgeAttributesImport().

Constraint: QtCore only — no widgets, no UI signals.

Function Documentation

◆ fromCSV()

ParsedTable TableImport::fromCSV ( const QString &  filePath)

Parses a CSV file at filePath into a ParsedTable.

The first non-empty line is treated as the header row. Quoted fields (RFC 4180) are handled: embedded double-quotes are written as two consecutive double-quotes ("").

Node attributes example — ID column is "#", native columns (Label, Size, Color, Shape) are routed to their setters; everything else becomes a custom attribute:

#,Label,Shape,type,year_founded
1,Alice,diamond,investor,2010
2,Bob,circle,founder,2018
3,Carol,box,advisor,2015

Edge attributes example — Source/Target identify the edge, rest become attributes:

Source,Target,relationship,weight
1,2,invested_in,0.8
2,3,mentors,0.5
1,3,co_founded,1.0

◆ fromJSON()

ParsedTable TableImport::fromJSON ( const QString &  filePath)

Parses a JSON file at filePath into a ParsedTable.

Expects a top-level JSON array of objects — the format produced by TableExport::toJSON(). Column order follows the key order of the first object in the array.

Node attributes example:

[
{ "#": "1", "Label": "Alice", "type": "investor", "year_founded": "2010" },
{ "#": "2", "Label": "Bob", "type": "founder", "year_founded": "2018" }
]

Edge attributes example:

[
{ "Source": "1", "Target": "2", "relationship": "invested_in", "weight": "0.8" },
{ "Source": "2", "Target": "3", "relationship": "mentors", "weight": "0.5" }
]

◆ parseCSVLine()

static QStringList TableImport::parseCSVLine ( const QString &  line)
static