processing organization bulk download using node js

Options

Hi guys, i would like to process this file (OpenPermID-bulk-organization-20191124_084723) using node js.

i have just created a node js command to download and uncompress gz files.

But, i can't be able to process that file.

I tried using N3 with/without streams...


Best Answer

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    @gelordi

    I have used the TTL file with this code.

    const N3 = require('n3');
    const fs = require('fs')
    const parser = new N3.Parser(),
    rdfStream = fs.createReadStream('OpenPermID-bulk-organization-20191201_084716.ttl');
    parser.parse(rdfStream, console.log);

    It showed this error:

    null Quad {
      subject: NamedNode { id: 'https://permid.org/1-5000487228'; },
      predicate:
       NamedNode { id: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type'; },
      object:
       NamedNode { id: 'http://permid.org/ontology/organization/Organization'; },
      graph: DefaultGraph { id: '' } }
    { Error: Undefined prefix "xsd:" on line 10.
        at N3Parser._error (C:\node_modules\n3\lib\N3Parser.js:845:15)
        at N3Parser._readEntity (C:\node_modules\n3\lib\N3Parser.js:188:47)
        at N3Parser._completeLiteral (C:\node_modules\n3\lib\N3Parser.js:517:29)
        at N3Parser._readDataTypeOrLang (C:\node_modules\n3\lib\N3Parser.js:503:17)
        at C:\node_modules\n3\lib\N3Parser.js:995:127
        at N3Lexer._tokenizeToEnd (C:\node_modules\n3\lib\N3Lexer.js:382:7)
        at ReadStream.<anonymous> (C:\node_modules\n3\lib\N3Lexer.js:524:22)
        at ReadStream.emit (events.js:189:13)
        at addChunk (_stream_readable.js:284:12)
        at readableAddChunk (_stream_readable.js:261:13)
      context:
       { token: { line: 10, type: 'type', value: 'string', prefix: 'xsd' },
         line: 10,
         previousToken: { line: 10, type: 'literal', value: 'Canada\n', prefix: '' } } }

    The problem can be solved by adding "@prefix xsd: <http://www.w3.org/2001/XMLSchema#&gt; ." at the beginning of the TTL file.

    imagePlease confirm the problem. Then I can contact the Open PermID support team to verify it.