Skip to main content

CLI tool to parse YSTAFDB and produce ttl/nt/xml.

Project description

YSTAFDB

YSTAFDB creates turtle files of the instances of data based on an ontology. The turtle files are needed for the BONSAI knowledge graph.

The turtle files generated are stored in the BONSAI rdf repository.

Currently generates the following:

  • Activity types, flow objects, locations and flows for YSTAFDB v1.0.

Installation

with package manager pip from pypi

Installable via pip:

pip install ystafdb

manual

Clone git repo

$ git clone git@github.com:BONSAMURAIS/ystafdb.git

Enter cloned repo

$ cd ystafdb

Now install package

$ python setup.py install

Usage

First download the Base Data, and then use ystafdb-cli to produce the ttl/nt/xml files.

For the full syntax, invoke ystafdb-cli -h:

usage: ystafdb-cli [-h] [-i INDIR] [-o OUTDIR] [-f {nt,ttl,xml}]

Extract rdf from ystafdb

optional arguments:
  -h, --help            show this help message and exit
  -i INDIR, --input INDIR
                        path to ystafdb csv files
  -o OUTDIR, --output OUTDIR
                        Output directory
  -f {nt,ttl,xml}, --format {nt,ttl,xml}
                        The output format

Download Base Data

The data can be downloaded here as a zip file.

Extract the contents of the zip file. As an example, the data can be placed under ystafdb-input. The following files from the Base Data are mandatory to have in the folder (ystafdb-input in our example):

  • material_names.csv
  • subsystems.csv
  • flows.csv
  • publications.csv
  • reference_spaces.csv
  • reference_materials.csv
  • reference_timeframes.csv

Under a Linux terminal, you can acomplish the previous two operations with:

curl -L "https://www.sciencebase.gov/catalog/file/get/5b9a7c28e4b0d966b485d915?f=__disk__0f%2F58%2Fa7%2F0f58a74db669ee5418f36a698bc85781e867e0ab" -o YSTAFDB_CSV_files.zip
unzip -d ystafdb-input YSTAFDB_CSV_files.zip

Generate the ttl or nt or xml files

If the package is correctly installed, you can use the command line tool ystafdb-cli to produce the rdfs as follows:

$ ystafdb-cli -i <indir> -o <outdir> -f [ttl|nt|xml]

Where:

  • <indir> is the location of the ystafdb csv files, and
  • <outdir> is the directory where the output triples graphs will be placed. This is optional, if not supplied, the output directory will be output
  • -f is the format of the files to generate (ttl, nt or xml). This is optional, if not supplied, it is ttl.

In the Linux terminal example from above, this would be done with:

ystafdb-cli -i ystafdb-input

The <outputdir> directory will have the following contents:

output
├── [ 4.0K]  activitytype
│   └── [ 4.0K]  ystafdb
│       └── [ 249K]  ystafdb.ttl
├── [ 4.0K]  flow
│   └── [ 4.0K]  ystafdb
│       └── [ 4.0K]  huse
│           └── [  41M]  huse.ttl
├── [ 4.0K]  flowobject
│   └── [ 4.0K]  ystafdb
│       └── [  63K]  ystafdb.ttl
├── [ 4.0K]  foaf
│   └── [ 4.0K]  ystafdb
│       └── [ 1.4K]  ystafdb.ttl
├── [ 4.0K]  location
│   └── [ 4.0K]  ystafdb
│       └── [ 158K]  ystafdb.ttl
└── [ 4.0K]  prov
    └── [ 4.0K]  ystafdb
        └── [ 1.0M]  ystafdb.ttl

Contributing

Please do not edit this package directly. All contributions should be via pull request.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ystafdb-0.6.0.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

ystafdb-0.6.0-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file ystafdb-0.6.0.tar.gz.

File metadata

  • Download URL: ystafdb-0.6.0.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for ystafdb-0.6.0.tar.gz
Algorithm Hash digest
SHA256 444ee1e874b61eb38a5886bf7cebf3a47414ad52d2fff38ce9794662a4d0348c
MD5 66183c9cf7e3f1d5db2e1a6e787dbb07
BLAKE2b-256 e2cc751c46ba5dba11dd74564af21791363cb064ba34b0d0ba9f9a8feb090762

See more details on using hashes here.

File details

Details for the file ystafdb-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: ystafdb-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for ystafdb-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6350a2b5146e2e487a90b1021f87cd3c0758022c62ae2ab5706d8ac3194b3c19
MD5 b562f9585717636e056fef67a4a4350a
BLAKE2b-256 5b0d5e5e5c4160a48645ad391dd606f288fea1a358ef043fba89d680781e65d0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page