Skip to main content

rdfx

A small Python utility to convert, merge, and read/persist RDF data in different formats, across different "persistence systems".

How to Use

The command line utility covers merge and conversion functionality, and simplifies certain aspects of this. The

Python

Run the rdfx.py script with Python having installed the packages required by requirements.txt.

BASH (Linux, Mac etc)

To utilise the command line util run: python rdfx.py *args

To convert a file: python rdfx.py convert myfile.ttl -f nt -o output_dir For multiple files: python rdfx.py convert myfile1.ttl myfile2.ttl -f nt -o output_dir A directory of files: python rdfx.py convert files_dir -f nt -o output_dir To merge multiple files: python rdfx.py merge myfile1.ttl myfile2.ttl -f nt -o output_dir To merge a directory of files: python rdfx.py merge files_dir -f nt -o output_dir To remove sort and remove unused prefixes in a turtle file: python rdfx.py clean myfile.ttl

To simplify usage of the command line utility at present, the following behaviour has been set:

Type Output Filenames
Merge merged.{format}
Convert file1.{format} file2.{format} ...

That is, when merging, the output filename will be "merged", with the correct file format. When converting, the output filename will be the same as the input filename, with the correct file format. This behaviour simplifies input to the command line util, allowing multiple files and directories to be input without confusion as to which specified filenames are for input or output, and mappings between input and output, especially directories or multiple files are converted/merged.

The python utilities behind the command line tool can be configured to set user specified filenames, for these cases use Python.

SOP / EDG usage

The SOP persistence system can be used to read and write to/from EDG master graphs and workflows. The SOP persistence system can be instantiated with the following optional parameters:

  1. location, defaults to "http://localhost:8083"
  2. username, defaults to "Administrator"
  3. password, defaults to ""
  4. timeout, defaults to 60 seconds Example instantiation with defaults:
from rdfx.persistence_systems import SOP
local_sop_ps = SOP()

The following methods are available on instances of the SOP class:

Method Paramters Returns
read graph URN
rdf_format
list of comments
RDFLib Graph
write RDFLib Graph
graph IRI
list of comments (optional)
The IRI of the created graph
query query
graph_iri
return_format
The query results
asset_collection_size asset_iri Triples count for the given asset
create_datagraph datagraph_name (optional)
description (optional)
subjectArea (optional)
default_namespace (optional)
HTTP headers (optional)
datagraph IRI
create_workflow graph_iri
workflow_name (optional)
HTTP headers (optional)
workflow IRI
create_manifest manifest_name (optional)
description (optional)
subjectArea (optional)
default_namespace (optional)
HTTP headers (optional)
the IRI for the manifest
asset_exists graph_name true/false

Command line tool documentation

These usage notes come from running the help command in the tool, e.g. python rdfx.ph -h:

usage: rdfx.py [-h] [--format {ttl,turtle,json,json-ld,jsonld,owl,xml,rdf,nt,n3}] [-o OUTPUT] [--comments COMMENTS] {convert,merge} data [data ...]

positional arguments:
  {convert,merge}
  data                  Path to the RDF file or directory of files for merging or conversion.

optional arguments:
  -h, --help            show this help message and exit
  --format {ttl,turtle,json,json-ld,jsonld,owl,xml,rdf,nt,n3}, -f {ttl,turtle,json,json-ld,jsonld,owl,xml,rdf,nt,n3}
                        The RDFlib token for the RDF format you want to convert the RDF file to.
  -o OUTPUT, --output OUTPUT
                        if set, the output location for merged or converted files, defaults to the current working directory
  --comments COMMENTS   Comments to prepend to the RDF, turtle only.

License

LGPL - see the LICENSE file for details

Dependencies

This uses RDFlib.

Contact

Original library: Nicholas J. Car Data Systems Architect SURROUND Australia Pty Ltd nicholas.car@surroundaustralia.com GitHub: nicholascar ORCID: https://orcid.org/0000-0002-8742-7730

Updates around persistence systems: David Habgood Application Architect SURROUND Australia Pty Ltd david.habgood@surroundaustrlaia.com GitHub: nicholascar https://orcid.org/0000-0002-3322-1868

Release files for rdfx 0.4.18

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rdfx 0.4.18
File Size Uploaded
rdfx-0.4.18.tar.gz 160.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rdfx 0.4.18
File Interpreter ABI Platform
rdfx-0.4.18-py3-none-any.whl Python 3 none any Details

Total release size: 320.6 kB

Release files / rdfx-0.4.18.tar.gz

Download URL rdfx-0.4.18.tar.gz
Size 160.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1c624b79f9aa83c7f4fe92de7359820f6c0420dd56ce8cb8ab0f1e0dbf76109c
BLAKE2b-256 checksum
How to use checksums
ff35a2c0a426eabb4eb2fc07b0101905b814b5af2795a6f42a25b66d8a5eef57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.7

Release files / rdfx-0.4.18-py3-none-any.whl

Download URL rdfx-0.4.18-py3-none-any.whl
Size 160.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8fa5fe18da4de7a320a8df042cc22f06b2101f907ff566b31e63495662d10a45
BLAKE2b-256 checksum
How to use checksums
588ef6c5a555e2938390a0c0821fad2fdd4db594f3578e12a0494997c5511e4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.7

Release history Release notifications | RSS feed

This release

0.4.18 This release

2 release files

0.4.17

2 release files

0.4.16

2 release files

0.4.12

1 release file

0.4.11

2 release files

0.4.10

2 release files

0.4.9

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page