semantica.export serializes knowledge graphs to every downstream format:
  • RDF: Turtle, JSON-LD, N-Triples, RDF/XML: with optional W3C PROV-O provenance inline
  • Analytics: Apache Parquet and Arrow for Spark, BigQuery, Databricks
  • Graph databases: Cypher CREATE statements for Neo4j; AQL INSERT for ArangoDB
  • Standard formats: GraphML, GEXF, Graphviz DOT, CSV, OWL 2.0
  • Vector export: NumPy .npz, FAISS index, binary for embedding pipelines

Exported Classes

ClassOutput formatsNotes
RDFExporterTurtle, JSON-LD, N-Triples, RDF/XMLexport_to_rdf() → string; export() → file
ParquetExporter.parquetRequires pyarrow; explicit typed schema
LPGExporterCypher CREATENeo4j and Memgraph compatible
ArangoAQLExporterAQL INSERTVertex and edge collections
GraphExporterGraphML, GEXF, Graphviz DOTStandard graph interchange formats
OWLExporterOWL 2.0 in Turtle/XMLOntology serialization
CSVExporter.csvexport_entities() and export_relationships()
VectorExporterJSON, NumPy .npz, FAISS index, binaryEmbedding vector export
ArrowExporterApache Arrow IPCRequires pyarrow; zero-copy transfer
DistanceExporterCSV, JSONLPairwise distance metrics; takes a graph arg
ReportGeneratorHTML, Markdown, JSON, plain textAnalytics reports
NamespaceManager:RDF namespace extraction and declaration generation

Getting Started

from semantica.export import RDFExporter

# Export a knowledge graph dict to Turtle
exporter = RDFExporter()
rdf_str = exporter.export_to_rdf(graph, format="turtle")
with open("output.ttl", "w") as f:
    f.write(rdf_str)
Or use the one-liner convenience functions:
from semantica.export import export_rdf, export_csv, export_lpg

export_rdf(graph,  "output.ttl",    format="turtle")
export_csv(graph,  "output_base")   # writes entities and relationships as CSV
export_lpg(graph,  "import.cypher", method="cypher")

Quick Export

1

Export to RDF string

from semantica.export import RDFExporter

exporter = RDFExporter()
rdf_str = exporter.export_to_rdf(graph, format="turtle")
2

Write RDF directly to file

exporter.export(graph, "output.ttl", format="turtle")
3

Columnar export for analytics

from semantica.export import ParquetExporter

exporter = ParquetExporter(compression="snappy")
exporter.export_entities(entities, "nodes.parquet")
exporter.export_relationships(relationships, "edges.parquet")
4

Graph database import

from semantica.export import LPGExporter

exporter = LPGExporter()
exporter.export(graph, "import.cypher")   # Cypher CREATE statements

Exporters

Export to W3C RDF formats: Turtle, JSON-LD, N-Triples, and RDF/XML.export_to_rdf() returns a string; export() writes to a file:
from semantica.export import RDFExporter

exporter = RDFExporter()

# Returns RDF string
turtle_str  = exporter.export_to_rdf(graph, format="turtle")   # Turtle
jsonld_str  = exporter.export_to_rdf(graph, format="jsonld")   # JSON-LD
nt_str      = exporter.export_to_rdf(graph, format="ntriples") # N-Triples
xml_str     = exporter.export_to_rdf(graph, format="rdfxml")   # RDF/XML

# Accepted format aliases: "ttl" -> turtle, "nt" -> ntriples, "xml" -> rdfxml,
# "json-ld" -> jsonld, "rdf" -> rdfxml

# Write directly to file
exporter.export(graph, "output.ttl", format="turtle")

# Also available
exporter.export_knowledge_graph(graph, "output.ttl", format="turtle")
export_to_rdf() returns a string: it does not write a file. Call export() or export_knowledge_graph() to write directly to disk.
Use export_to_rdf() + string for inspection, export() for production. In notebooks or debug sessions, export_to_rdf() is handy for quick inspection. For CI pipelines and pipelines writing files, export() is a single call.
Use turtle for human readability, ntriples for streaming. Turtle is compact and readable for debugging and sharing. N-Triples (.nt) is line-oriented: one triple per line: making it safe to stream, concatenate, and process with standard Unix tools.
Namespace management:
from semantica.export import NamespaceManager, RDFExporter

ns_manager = NamespaceManager()
# ns_manager.namespaces contains the built-in prefix dict (rdf, rdfs, owl, xsd, semantica)
# Add custom namespaces by updating the dict directly
ns_manager.namespaces["ex"]     = "http://example.org/"
ns_manager.namespaces["schema"] = "https://schema.org/"

# Generate Turtle prefix declarations
decls = ns_manager.generate_namespace_declarations(
    ns_manager.namespaces, format="turtle"
)
print(decls)   # @prefix ex: <http://example.org/> .   etc.
Temporal export (OWL-Time):
# Pass include_temporal=True to embed OWL-Time interval triples
turtle_str = exporter.export_to_rdf(
    graph,
    format="turtle",
    include_temporal=True,
    time_axis="valid",  # "valid" | "transaction" | "both"
)

Convenience Functions

from semantica.export import (
    export_rdf, export_json, export_parquet, export_csv,
    export_lpg, export_arango, export_graph, export_owl,
    export_vector, export_arrow, export_yaml, generate_report,
)

export_rdf(graph,     "output.ttl",    format="turtle")
export_rdf(graph,     "output.nt",     format="ntriples")
export_json(graph,    "output.json",   format="json")
export_parquet(graph, "output_base",   compression="snappy")
export_csv(graph,     "output_base")   # uses CSVExporter.export()
export_lpg(graph,     "import.cypher", method="cypher")
export_arango(graph,  "import.aql")
export_graph(graph,   "graph.graphml", format="graphml")
export_owl(ontology,  "ontology.owl",  format="owl-xml")
export_vector(vectors,"vectors.json",  format="json")
export_arrow(graph,   "graph.arrow")
export_yaml(graph,    "graph.yaml",    method="semantic_network")
generate_report(data, "report.html",   format="html")
The export_csv convenience function delegates to CSVExporter.export(). For per-type exports use the class directly (exporter.export_entities(), exporter.export_relationships()).

Format Reference

Format stringCanonical nameExporterFile extBest for
"turtle" / "ttl"turtleRDFExporter.ttlReadable RDF, ontology sharing
"jsonld" / "json-ld"jsonldRDFExporter.jsonldAPIs, Linked Data, JSON pipelines
"ntriples" / "nt"ntriplesRDFExporter.ntStreaming RDF, line-by-line processing
"rdfxml" / "xml" / "rdf"rdfxmlRDFExporter.rdfW3C RDF/XML, broadest compatibility
"parquet"parquetParquetExporter.parquetSpark, BigQuery, Databricks, Snowflake
"cypher"cypherLPGExporter.cypherNeo4j, Memgraph import
"aql"aqlArangoAQLExporter.aqlArangoDB vertex + edge collections
"graphml"graphmlGraphExporter.graphmlGephi, yEd visualization
"gexf"gexfGraphExporter.gexfGephi streaming format
"dot"dotGraphExporter.dotGraphviz rendering
"owl-xml"owl-xmlOWLExporter.owlOWL 2.0 ontology distribution
"csv"csvCSVExporter.csvSpreadsheets, simple pipelines
"yaml"yamlSemanticNetworkYAMLExporter.yamlHuman-readable config-driven use
"arrow"arrowArrowExporter.arrowZero-copy inter-process transfer
"json"jsonVectorExporter.jsonVector embeddings
"numpy"numpyVectorExporter.npzNumPy arrays from embeddings
"binary"binaryVectorExporter.binRaw float32 binary
"faiss"faissVectorExporter.faissDirect FAISS index files
"html" / "markdown" / "json" / "text":ReportGenerator.html / .md / .json / .txtAnalytics reports
Match your export format to your consumer. Neo4j → cypher; ArangoDB → aql; Gephi/yEd → graphml or gexf; semantic web tools → turtle or json-ld; analytics pipelines → parquet; zero-copy IPC → arrow.

Triplet Store

Store RDF exports in a SPARQL-queryable backend.

Ontology

Export OWL ontologies.

Provenance

Include provenance metadata in RDF exports.

Pipeline

Add export as a final pipeline step.