Skip to content
Snippets Groups Projects
import-recursive-xz-rdf-to-virtuoso.sh 743 B
Newer Older
  • Learn to ignore specific revisions
  • Andreas Schärtl's avatar
    Andreas Schärtl committed
    #! /bin/sh
    
    # Recursivly search the current directory for *.rdf.xz files,
    # extract them and add them to the Virtuoso DB.
    
    set -eu
    
    # temp file that contains the current rdf file, extracted
    # from .xz
    EXTRACTED_FILE="/tmp/extracted.rdf"
    
    # the file that contains the query to execute; virtuso
    # doesn't want to read queries from shell args apperently
    QUERY_FILE="/tmp/query.sparql"
    
    # the graph to put all nodes into
    GRAPH="http://mymath.org"
    
    files=$(find . -name "*.rdf.xz")
    
    for file in $files; do
        echo "$0: looking at $file" 1>&2
        xzcat "$file" > $EXTRACTED_FILE
        query="DB.DBA.RDF_LOAD_RDFXML_MT (file_to_string_output('$EXTRACTED_FILE'), '', '$GRAPH');"
        echo "$query" > $QUERY_FILE
        isql-v 1111 dba dba $QUERY_FILE
    done