Data Format Parsing

Comprehensive examples of parsing CSV, JSON, RDF, and other formats into QualiaDB

CSV Parsing

Ingest writes a unified Q42 v3 volume (Q42\0 header, embedded Q42LEX / BIDX / FIDX / PIDX, LZ4 SuperBlocks). There is no sibling .c.q42 or .q42.lex — compression and lexicon live inside the single .q42.

QualiaDB can ingest CSV files and convert them to semantic triples. Here's how to parse a CSV with person data:

Input CSV (people.csv)

name,age,city
Alice Smith,30,New York
Bob Jones,35,Los Angeles
Carol White,28,Chicago

Conversion Command

qualia ingest --format csv people.csv people.q42 --mapping "name=ex:name,age=ex:age,city=ex:city"

Resulting Triples (Turtle)

@prefix ex:  .

_:row1 a ex:Person ;
    ex:name "Alice Smith" ;
    ex:age 30 ;
    ex:city "New York" .

_:row2 a ex:Person ;
    ex:name "Bob Jones" ;
    ex:age 35 ;
    ex:city "Los Angeles" .

_:row3 a ex:Person ;
    ex:name "Carol White" ;
    ex:age 28 ;
    ex:city "Chicago" .

JSON / JSON-LD Parsing

JSON-LD is the preferred JSON format for semantic data. QualiaDB supports both plain JSON and JSON-LD:

Input JSON-LD (data.jsonld)

{
  "@context": {
    "name": "http://example.org/name",
    "age": "http://example.org/age",
    "knows": "http://example.org/knows"
  },
  "@graph": [
    {
      "@id": "http://example.org/alice",
      "@type": "Person",
      "name": "Alice Smith",
      "age": 30,
      "knows": "http://example.org/bob"
    },
    {
      "@id": "http://example.org/bob",
      "@type": "Person",
      "name": "Bob Jones",
      "age": 35
    }
  ]
}

Conversion Command

qualia ingest data.jsonld data.q42

Plain JSON with Schema

For plain JSON, provide a JSON-LD context to map keys to predicates:

{
  "context": {
    "name": "http://example.org/name",
    "age": "http://example.org/age"
  },
  "data": [
    {"name": "Alice", "age": 30},
    {"name": "Bob", "age": 35}
  ]
}

RDF Format Parsing

QualiaDB supports multiple RDF serializations:

Turtle (.ttl)

@prefix ex:  .

ex:alice a ex:Person ;
    ex:name "Alice" ;
    ex:age 30 .

N-Triples (.nt)

   .
  "Alice" .
  "30"^^ .

RDF/XML (.rdf)


  
    
    Alice
    30
  

N-Quads (.nq)

  "Alice"  .
  "30"^^  .

Ingest Commands

# Turtle
qualia ingest data.ttl data.q42

# N-Triples
qualia ingest data.nt data.q42

# RDF/XML
qualia ingest data.rdf data.q42

# N-Quads (with named graphs)
qualia ingest data.nq data.q42

CBOR-LD (Native Format)

CBOR-LD is QualiaDB's native binary format. It provides the most efficient storage and zero-allocation parsing:

Why CBOR-LD?

Export to CBOR-LD

qualia export --format cbor-ld data.q42 data.cborld

Import from CBOR-LD

qualia ingest data.cborld data.q42

Performance Comparison

Benchmark results for ingesting a 100K triple dataset (WordNet subset):

Format File Size Ingest Time Memory Usage
Turtle 15.2 MB 2.3s 45 MB
N-Triples 18.7 MB 1.8s 38 MB
JSON-LD 22.1 MB 3.1s 52 MB
CBOR-LD 8.4 MB 0.9s 28 MB
.q42 (Native) 2.1 MB 0.0s (mmap) 12 MB

* Benchmarks run on 512 MB constraint, measured with native CLI